-
-
Notifications
You must be signed in to change notification settings - Fork 334
[16.0][ADD] account_edi_ubl_cii_purchase_match #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 16.0
Are you sure you want to change the base?
[16.0][ADD] account_edi_ubl_cii_purchase_match #1267
Conversation
Extend UBL vendor bill import to automatically match and link bill lines to purchase order lines using the OrderReference and product label
|
cc/ @phschmidt , @jbaudoux , @rousseldenis |
phschmidt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional review
| [ | ||
| "|", | ||
| ("name", "=", order_ref), | ||
| ("partner_ref", "=", order_ref), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partner_ref should compare to OrderReference/SalesOrderID and not OrderReference/ID
| res = super()._import_fill_invoice_form(journal, tree, invoice, qty_factor) | ||
| if journal.type != "purchase": | ||
| return res | ||
| invoice_origin_node = tree.find("./{*}OrderReference/{*}ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should only search for the parent here as ID is mandatory when the parent is there and then parse ID and SalesOrderID
| invoice_origin_node = tree.find("./{*}OrderReference/{*}ID") | ||
| if invoice_origin_node is None: | ||
| return res | ||
| order_ref = invoice_origin_node.text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then handover this to the called method below
| if invoice_line.purchase_line_id: | ||
| return False | ||
| product = self._get_matching_product(invoice_line) | ||
| purchase_line = purchase_lines.filtered(lambda line: line.product_id == product) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if no product is found and there are PO lines without product?
| purchase_line = purchase_lines.filtered(lambda line: line.product_id == product) | |
| purchase_line = purchase_lines.filtered(lambda line: line.product_id and line.product_id == product) |
| res = super()._import_fill_invoice_line_form( | ||
| journal, tree, invoice, invoice_line, qty_factor | ||
| ) | ||
| supplier_product_code = self._find_value( | ||
| "./cac:Item/cac:SellersItemIdentification/cbc:ID", tree | ||
| ) | ||
| if invoice_line.product_id or not supplier_product_code: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is I think a bug in the call to super that retrieves the product. It's searching for a product with default_code based on the SellersItemIdentification while it should be BuyersItemIdentification
https://github.com/odoo/odoo/blob/f07949e4ccdb5d7a17a6678b008fa6785ec3fb12/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py#L727
I would force a new call to the method _retrieve_product with the right argument
| invoice_line.purchase_line_id = purchase_line | ||
| return True | ||
|
|
||
| def _get_matching_product(self, invoice_line): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this? The product matching should already be resolved by _retrieve_product and what you improved in _import_fill_invoice_line_form?
What could be usefull is to match a PO line name based on the invoice line name, in case the seller or buyer does not manage the line with a product
debf5ad to
7b6468c
Compare
…hase line form view
7b6468c to
ed80be9
Compare
Extend UBL vendor bill import to automatically match and link bill lines to purchase order lines using the OrderReference and product label