diff --git a/account_ebics/models/ebics_config.py b/account_ebics/models/ebics_config.py index 5582092..8d6ed40 100644 --- a/account_ebics/models/ebics_config.py +++ b/account_ebics/models/ebics_config.py @@ -120,7 +120,8 @@ class EbicsConfig(models.Model): comodel_name="res.company", relation="ebics_config_res_company_rel", string="Companies", - readonly=True, + compute="_compute_company_ids", + store=True, help="Companies sharing this EBICS contract.", ) @@ -154,26 +155,10 @@ class EbicsConfig(models.Model): ) ) - def write(self, vals): - """ - Due to the multi-company nature of the EBICS config we - need to adapt the company_ids in the write method. - """ - if "journal_ids" not in vals: - return super().write(vals) + @api.depends("journal_ids.company_id") + def _compute_company_ids(self): for rec in self: - old_company_ids = rec.journal_ids.mapped("company_id").ids - super(EbicsConfig, rec).write(vals) - new_company_ids = rec.journal_ids.mapped("company_id").ids - updates = [] - for cid in new_company_ids: - if cid in old_company_ids: - old_company_ids.remove(cid) - else: - updates += [(4, cid)] - updates += [(3, x) for x in old_company_ids] - super(EbicsConfig, rec).write({"company_ids": updates}) - return True + rec.company_ids = rec.journal_ids.mapped("company_id") def unlink(self): for ebics_config in self: diff --git a/account_ebics/views/menu.xml b/account_ebics/views/menu.xml index 0ac9cee..db44e5b 100644 --- a/account_ebics/views/menu.xml +++ b/account_ebics/views/menu.xml @@ -82,4 +82,13 @@ sequence="30" /> + + diff --git a/account_ebics/wizards/ebics_xfer.py b/account_ebics/wizards/ebics_xfer.py index e300f09..8bb82d6 100644 --- a/account_ebics/wizards/ebics_xfer.py +++ b/account_ebics/wizards/ebics_xfer.py @@ -263,7 +263,8 @@ class EbicsXfer(models.TransientModel): } } data = client.download(df.order_type, params=params) - ebics_files += self._handle_download_data(data, df) + if not self.env.context.get("ebics_mark_as_downloaded"): + ebics_files += self._handle_download_data(data, df) success = True except EbicsFunctionalError: err_cnt += 1 diff --git a/account_ebics/wizards/ebics_xfer.xml b/account_ebics/wizards/ebics_xfer.xml index ceb9905..3e329e9 100644 --- a/account_ebics/wizards/ebics_xfer.xml +++ b/account_ebics/wizards/ebics_xfer.xml @@ -169,4 +169,73 @@ + + Mark EBICS files as Downloaded + ebics.xfer + 1 + +
+ + + + + + + + + + +
+
+
+
+
+ + + Mark files as Downloaded + ir.actions.act_window + ebics.xfer + form + new + {'ebics_download': 1, 'ebics_mark_as_downloaded': 1} + + +