Skip to content
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 name for line with royalty product #5

Open
wants to merge 1 commit into
base: 10-mig-multi-cpny-hold-inv
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions multi_company_holding_invoicing/wizards/base_invoicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,27 @@ def _get_invoice_line_data(self, data):

@api.model
def _prepare_invoice_line(self, data_line):
val_line = super(ChildInvoicing, self).\
_prepare_invoice_line(data_line)
if data_line.get('__domain'):
order_ids = self.env['sale.order'].search(
data_line['__domain']).ids
line_ids = self.env['sale.order.line'].search([
('order_id', 'in', order_ids)]).ids
val_line['sale_line_ids'] = [(6, 0, line_ids)]
# TODO the code is too complicated
# we should simplify the _get_invoice_line_data
# and _prepare_invoice_line to avoid this kind of hack
if data_line.get('name') == 'royalty':
agree = self.env['agreement'].browse(
data_line['agreement_id'][0])
val_line.update(self._get_accounting_value_from_product(
data_line,
agree.holding_royalty_product_id))
val_line['name'] = agree.holding_royalty_product_id.name
val_line = self._get_accounting_value_from_product(
data_line, agree.holding_royalty_product_id)
val_line.update({
'price_unit': data_line['amount_untaxed'],
'quantity': data_line.get('quantity', 1),
})
else:
val_line = super(ChildInvoicing, self).\
_prepare_invoice_line(data_line)
if data_line.get('__domain'):
order_ids = self.env['sale.order'].search(
data_line['__domain']).ids
line_ids = self.env['sale.order.line'].search([
('order_id', 'in', order_ids)]).ids
val_line['sale_line_ids'] = [(6, 0, line_ids)]
return val_line

@api.model
Expand Down