diff --git a/invoice.py b/invoice.py index 5d58d2e4bb..78756eb004 100644 --- a/invoice.py +++ b/invoice.py @@ -330,9 +330,9 @@ class Invoice(Workflow, ModelSQL, ModelView): payment_term = self.party.supplier_payment_term if self.company and self.type in ('out_credit_note', 'in_credit_note'): if self.type == 'out_credit_note': - payment_term = self.company.customer_payment_term + payment_term = self.company.party.customer_payment_term else: - payment_term = self.company.supplier_payment_term + payment_term = self.company.party.supplier_payment_term if account: result['account'] = account.id result['account.rec_name'] = account.rec_name diff --git a/tests/scenario_invoice.rst b/tests/scenario_invoice.rst index a26189ed9e..92a22616b8 100644 --- a/tests/scenario_invoice.rst +++ b/tests/scenario_invoice.rst @@ -38,10 +38,13 @@ Create company:: ... else: ... currency, = currencies >>> Company = Model.get('company.company') + >>> Party = Model.get('party.party') >>> company_config = Wizard('company.company.config') >>> company_config.execute('company') >>> company = company_config.form - >>> company.name = 'Dunder Mifflin' + >>> party = Party(name='Dunder Mifflin') + >>> party.save() + >>> company.party = party >>> company.currency = currency >>> company_config.execute('add') >>> company, = Company.find([]) @@ -144,16 +147,20 @@ Create product:: >>> ProductUom = Model.get('product.uom') >>> unit, = ProductUom.find([('name', '=', 'Unit')]) + >>> ProductTemplate = Model.get('product.template') >>> Product = Model.get('product.product') >>> product = Product() - >>> product.name = 'product' - >>> product.default_uom = unit - >>> product.type = 'service' - >>> product.list_price = Decimal('40') - >>> product.cost_price = Decimal('25') - >>> product.account_expense = expense - >>> product.account_revenue = revenue - >>> product.customer_taxes.append(tax) + >>> template = ProductTemplate() + >>> template.name = 'product' + >>> template.default_uom = unit + >>> template.type = 'service' + >>> template.list_price = Decimal('40') + >>> template.cost_price = Decimal('25') + >>> template.account_expense = expense + >>> template.account_revenue = revenue + >>> template.customer_taxes.append(tax) + >>> template.save() + >>> product.template = template >>> product.save() Create payment term:: diff --git a/tests/scenario_invoice_supplier.rst b/tests/scenario_invoice_supplier.rst index a8c5c0e7ac..5e08afe5d2 100644 --- a/tests/scenario_invoice_supplier.rst +++ b/tests/scenario_invoice_supplier.rst @@ -38,10 +38,13 @@ Create company:: ... else: ... currency, = currencies >>> Company = Model.get('company.company') + >>> Party = Model.get('party.party') >>> company_config = Wizard('company.company.config') >>> company_config.execute('company') >>> company = company_config.form - >>> company.name = 'Dunder Mifflin' + >>> party = Party(name='Dunder Mifflin') + >>> party.save() + >>> company.party = party >>> company.currency = currency >>> company_config.execute('add') >>> company, = Company.find([]) @@ -144,16 +147,20 @@ Create product:: >>> ProductUom = Model.get('product.uom') >>> unit, = ProductUom.find([('name', '=', 'Unit')]) + >>> ProductTemplate = Model.get('product.template') >>> Product = Model.get('product.product') >>> product = Product() - >>> product.name = 'product' - >>> product.default_uom = unit - >>> product.type = 'service' - >>> product.list_price = Decimal('40') - >>> product.cost_price = Decimal('20') - >>> product.account_expense = expense - >>> product.account_revenue = revenue - >>> product.supplier_taxes.append(tax) + >>> template = ProductTemplate() + >>> template.name = 'product' + >>> template.default_uom = unit + >>> template.type = 'service' + >>> template.list_price = Decimal('40') + >>> template.cost_price = Decimal('20') + >>> template.account_expense = expense + >>> template.account_revenue = revenue + >>> template.supplier_taxes.append(tax) + >>> template.save() + >>> product.template = template >>> product.save() Create payment term::