diff --git a/purchase_unreconciled/models/__init__.py b/purchase_unreconciled/models/__init__.py index 925c5320e37..b937ab13ceb 100644 --- a/purchase_unreconciled/models/__init__.py +++ b/purchase_unreconciled/models/__init__.py @@ -1,4 +1,5 @@ from . import purchase_order from . import company from . import res_config_settings +from . import account_move from . import account_move_line diff --git a/purchase_unreconciled/models/account_move.py b/purchase_unreconciled/models/account_move.py new file mode 100644 index 00000000000..b8e0e144a43 --- /dev/null +++ b/purchase_unreconciled/models/account_move.py @@ -0,0 +1,7 @@ +from odoo import fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + purchase_order_writeoff = fields.Boolean() diff --git a/purchase_unreconciled/models/account_move_line.py b/purchase_unreconciled/models/account_move_line.py index 6c58a996920..e46d48f62c9 100644 --- a/purchase_unreconciled/models/account_move_line.py +++ b/purchase_unreconciled/models/account_move_line.py @@ -33,7 +33,7 @@ def _get_writeoff_amounts(self): same_curr, ) - def _create_writeoff(self, writeoff_vals): + def _create_po_writeoff(self, writeoff_vals): ( amount_writeoff, amount_writeoff_curr, @@ -72,6 +72,7 @@ def _create_writeoff(self, writeoff_vals): "journal_id": writeoff_vals["journal_id"], "currency_id": writeoff_vals.get("currency_id", False), "line_ids": [(0, 0, write_off_vals), (0, 0, counter_part)], + "purchase_order_writeoff": True, } ) if writeoff_vals.get("purchase_order_id", False): diff --git a/purchase_unreconciled/models/purchase_order.py b/purchase_unreconciled/models/purchase_order.py index 85a8f070421..778e9ec9b10 100644 --- a/purchase_unreconciled/models/purchase_order.py +++ b/purchase_unreconciled/models/purchase_order.py @@ -160,7 +160,7 @@ def action_reconcile(self): writeoff_vals = self._get_purchase_writeoff_vals( unreconciled_items_group, purchase_line_id, product_id ) - writeoff_to_reconcile = unreconciled_items_group._create_writeoff( + writeoff_to_reconcile = unreconciled_items_group._create_po_writeoff( writeoff_vals ) all_writeoffs |= writeoff_to_reconcile