-
Notifications
You must be signed in to change notification settings - Fork 23.2k
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
[FIX] sale_stock: fix singleton error on invoice line with multiple sales line #163766
[FIX] sale_stock: fix singleton error on invoice line with multiple sales line #163766
Conversation
…ales line The issue: When creating an invoice from multiple sale orders, each invoice line is going to be linked to the appropriate sale order line from each sale order, which will cause a singleton traceback when trying to access the is_downpayment field Expected behavior: to confirm the invoice Current Behavior: Singleton traceback opw-3878327
Hello @odoo/rd-logistics , Could someone please have a look at this PR? Thanks |
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.
Hello,
As discussed in DM:
The code is sound but the issue doesn't appear reproducible as each sale line creates its own invoice line, based on this here:
odoo/addons/sale/models/sale_order_line.py
Lines 1126 to 1151 in 71227db
def _prepare_invoice_line(self, **optional_values): | |
"""Prepare the values to create the new invoice line for a sales order line. | |
:param optional_values: any parameter that should be added to the returned invoice line | |
:rtype: dict | |
""" | |
self.ensure_one() | |
res = { | |
'display_type': self.display_type or 'product', | |
'sequence': self.sequence, | |
'name': self.name, | |
'product_id': self.product_id.id, | |
'product_uom_id': self.product_uom.id, | |
'quantity': self.qty_to_invoice, | |
'discount': self.discount, | |
'price_unit': self.price_unit, | |
'tax_ids': [Command.set(self.tax_id.ids)], | |
'sale_line_ids': [Command.link(self.id)], | |
'is_downpayment': self.is_downpayment, | |
} | |
self._set_analytic_distribution(res, **optional_values) | |
if optional_values: | |
res.update(optional_values) | |
if self.display_type: | |
res['account_id'] = False | |
return res |
If you manage to reproduce it on a fresh DB/runbot, please update your commit and PR message with the steps to take.
@Sehnde You tried to do a return / credit note / return of return. Invoice again? |
@amoyaux just did, here are my steps:
This is expected because the number of SO lines does not vary and each SO line creates a single invoice line at confirmation. Even if the total amount of invoice lines is higher due to multiple invoices, the |
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.
even if there's no bug, it is safer to use any
+ mapped
with a Many2Many field
robodoo r+ |
…ales line The issue: When creating an invoice from multiple sale orders, each invoice line is going to be linked to the appropriate sale order line from each sale order, which will cause a singleton traceback when trying to access the is_downpayment field Expected behavior: to confirm the invoice Current Behavior: Singleton traceback opw-3878327 closes #163766 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
The issue:
When creating an invoice from multiple sale orders, each invoice line is going to be linked to the appropriate sale order line from each sale order, which will cause a singleton traceback when trying to access the is_downpayment field
Expected behavior:
to confirm the invoice
Current Behavior:
Singleton traceback
opw-3878327