Skip to content

Commit

Permalink
Merge PR #3348 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
OCA-git-bot committed Oct 22, 2024
2 parents d1b4b89 + 4eb5cbc commit 0eff562
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sale_automatic_workflow/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class AccountMove(models.Model):
_inherit = "account.move"

workflow_process_id = fields.Many2one(
comodel_name="sale.workflow.process", string="Sale Workflow Process"
comodel_name="sale.workflow.process", string="Sale Workflow Process", copy=False
)
2 changes: 2 additions & 0 deletions sale_automatic_workflow/models/automatic_workflow_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def _prepare_dict_account_payment(self, invoice):
"partner_id": invoice.partner_id.id,
"partner_type": partner_type,
"date": fields.Date.context_today(self),
"currency_id": invoice.currency_id.id,
}

@api.model
Expand Down Expand Up @@ -169,6 +170,7 @@ def _register_payment_invoice(self, invoice):
(payment_lines + lines).filtered_domain(
[("account_id", "=", account.id), ("reconciled", "=", False)]
).reconcile()
return payment

@api.model
def _handle_pickings(self, sale_workflow):
Expand Down
1 change: 1 addition & 0 deletions sale_automatic_workflow/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SaleOrder(models.Model):
comodel_name="sale.workflow.process",
string="Automatic Workflow",
ondelete="restrict",
copy=False,
)
all_qty_delivered = fields.Boolean(
compute="_compute_all_qty_delivered",
Expand Down
61 changes: 61 additions & 0 deletions sale_automatic_workflow/tests/test_automatic_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ def test_06_journal_on_invoice(self):
invoice = sale.invoice_ids
self.assertEqual(invoice.journal_id.id, new_sale_journal.id)

def test_no_copy(self):
workflow = self.create_full_automatic()
sale = self.create_sale_order(workflow)
self.run_job()
invoice = sale.invoice_ids
self.assertTrue(sale.workflow_process_id)
self.assertTrue(invoice.workflow_process_id)
sale2 = sale.copy()
invoice2 = invoice.copy()
self.assertFalse(sale2.workflow_process_id)
self.assertFalse(invoice2.workflow_process_id)

def test_automatic_sale_order_confirmation_mail(self):
workflow = self.create_full_automatic()
workflow.send_order_confirmation_mail = True
Expand All @@ -152,3 +164,52 @@ def test_automatic_sale_order_confirmation_mail(self):
lambda x: x.subtype_id == self.env.ref("mail.mt_comment")
)
)

def test_create_payment_with_invoice_currency_id(self):
workflow = self.create_full_automatic()
pricelist_id = self.env["product.pricelist"].create(
{
"name": "default_pricelist",
"currency_id": 1,
}
)
product_service = self.env["product.product"].create(
{
"name": "Remodeling Service",
"categ_id": self.env.ref("product.product_category_3").id,
"standard_price": 40.0,
"list_price": 90.0,
"type": "service",
"uom_id": self.env.ref("uom.product_uom_hour").id,
"uom_po_id": self.env.ref("uom.product_uom_hour").id,
"description": "Example of product to invoice on order",
"default_code": "PRE-PAID",
"invoice_policy": "order",
}
)
product_uom_hour = self.env.ref("uom.product_uom_hour")
override = {
"pricelist_id": pricelist_id.id,
"order_line": [
(
0,
0,
{
"name": "Prepaid Consulting",
"product_id": product_service.id,
"product_uom_qty": 1,
"product_uom": product_uom_hour.id,
},
)
],
}
sale = self.create_sale_order(workflow, override=override)
self.run_job()
self.assertTrue(sale.invoice_ids)
invoice = sale.invoice_ids
self.assertEqual(invoice.state, "posted")
payment_id = self.env["automatic.workflow.job"]._register_payment_invoice(
invoice
)
self.assertTrue(payment_id)
self.assertEqual(invoice.currency_id.id, payment_id.currency_id.id)

0 comments on commit 0eff562

Please sign in to comment.