Skip to content

Commit bc881c1

Browse files
jcouxSodexisTeam
authored andcommitted
[FIX] Fix sale_automatic_workflow_payment_mode migration
Parts of `sale_automatic_workflow_payment_mode` have been merged into `sale_automatic_workflow`. But these parts have been not removed from `sale_automatic_workflow_payment_mode`. This PR clean both modules after this merge. Originals PR of the merge: OCA#1789 (forwrd port of c8d59ed)
1 parent 92a37ec commit bc881c1

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

sale_automatic_workflow/data/automatic_workflow_data.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
>[('state', '=', 'sale'),('invoice_status','=','invoiced')]</field>
4343
<field name="user_id" ref="base.user_root" />
4444
</record>
45+
<record id="automatic_workflow_payment_filter" model="ir.filters">
46+
<field name="name">Automatic Workflow Payment Filter</field>
47+
<field name="model_id">account.move</field>
48+
<field
49+
name="domain"
50+
>[('state', '=', 'posted'), ('move_type', '=', 'out_invoice'), ('payment_state','!=','paid')]</field>
51+
<field name="user_id" ref="base.user_root" />
52+
</record>
4553
<record id="automatic_validation" model="sale.workflow.process">
4654
<field name="name">Automatic</field>
4755
<field name="picking_policy">one</field>
@@ -63,6 +71,8 @@
6371
<field name="picking_filter_id" eval="automatic_workflow_picking_filter" />
6472
<field name="sale_done" eval="0" />
6573
<field name="sale_done_filter_id" eval="automatic_workflow_sale_done_filter" />
74+
<field name="register_payment" eval="0" />
75+
<field name="payment_filter_id" ref="automatic_workflow_payment_filter" />
6676
<field
6777
name="warning"
6878
>Be careful, if you save the order with this setting, it could be auto-confirmed, even if you are editing it.</field>
@@ -85,6 +95,8 @@
8595
/>
8696
<field name="picking_filter_id" eval="automatic_workflow_picking_filter" />
8797
<field name="sale_done_filter_id" eval="automatic_workflow_sale_done_filter" />
98+
<field name="register_payment" eval="0" />
99+
<field name="payment_filter_id" ref="automatic_workflow_payment_filter" />
88100
</record>
89101
<record forcecreate="True" id="ir_cron_automatic_workflow_job" model="ir.cron">
90102
<field name="name">Automatic Workflow Job</field>

sale_automatic_workflow/models/automatic_workflow_job.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,26 +174,26 @@ def _register_payments(self, payment_filter):
174174
invoices = invoice_obj.search(payment_filter)
175175
_logger.debug("Invoices to Register Payment: %s", invoices.ids)
176176
for invoice in invoices:
177-
self._register_payment_invoice(invoice)
177+
with savepoint(self.env.cr):
178+
self._register_payment_invoice(invoice)
178179
return
179180

180181
def _register_payment_invoice(self, invoice):
181-
with savepoint(self.env.cr):
182-
payment = self.env["account.payment"].create(
183-
self._prepare_dict_account_payment(invoice)
184-
)
185-
payment.action_post()
186-
187-
domain = [
188-
("account_internal_type", "in", ("receivable", "payable")),
189-
("reconciled", "=", False),
190-
]
191-
payment_lines = payment.line_ids.filtered_domain(domain)
192-
lines = invoice.line_ids
193-
for account in payment_lines.account_id:
194-
(payment_lines + lines).filtered_domain(
195-
[("account_id", "=", account.id), ("reconciled", "=", False)]
196-
).reconcile()
182+
payment = self.env["account.payment"].create(
183+
self._prepare_dict_account_payment(invoice)
184+
)
185+
payment.action_post()
186+
187+
domain = [
188+
("account_internal_type", "in", ("receivable", "payable")),
189+
("reconciled", "=", False),
190+
]
191+
payment_lines = payment.line_ids.filtered_domain(domain)
192+
lines = invoice.line_ids
193+
for account in payment_lines.account_id:
194+
(payment_lines + lines).filtered_domain(
195+
[("account_id", "=", account.id), ("reconciled", "=", False)]
196+
).reconcile()
197197

198198
@api.model
199199
def run_with_workflow(self, sale_workflow):

sale_automatic_workflow/models/sale_workflow_process.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ def _default_filter(self, xmlid):
2727
return record
2828
return self.env["ir.filters"].browse()
2929

30-
@api.model
31-
def _default_payment_filter_id(self):
32-
return self.env["ir.filters"].browse()
33-
3430
name = fields.Char()
3531
picking_policy = fields.Selection(
3632
selection=[
@@ -126,7 +122,9 @@ def _default_payment_filter_id(self):
126122
payment_filter_id = fields.Many2one(
127123
comodel_name="ir.filters",
128124
string="Register Payment Invoice Filter",
129-
default=lambda x: x._default_payment_filter_id(),
125+
default=lambda self: self._default_filter(
126+
"sale_automatic_workflow.automatic_workflow_payment_filter"
127+
),
130128
)
131129
register_payment = fields.Boolean()
132130
payment_filter_domain = fields.Text(

0 commit comments

Comments
 (0)