diff --git a/asset.py b/asset.py index 2a601cba98..c0b1f16af1 100644 --- a/asset.py +++ b/asset.py @@ -49,7 +49,7 @@ class Asset(Workflow, ModelSQL, ModelView): ('product', '=', -1), ('product', '=', Eval('product', -1)), ), - ('invoice.type', '=', 'in_invoice'), + ('invoice.type', '=', 'in'), ['OR', ('company', '=', Eval('company', -1)), ('invoice.company', '=', Eval('company', -1)), diff --git a/invoice.py b/invoice.py index 0971284fb5..4cf362d50f 100644 --- a/invoice.py +++ b/invoice.py @@ -17,7 +17,7 @@ class InvoiceLine: states={ 'invisible': (~Eval('is_assets_depreciable', False) | (Eval('_parent_invoice', {}).get('type', - Eval('invoice_type')) != 'out_invoice')), + Eval('invoice_type')) != 'out')), }, depends=['product', 'is_assets_depreciable']) is_assets_depreciable = fields.Function(fields.Boolean( @@ -41,7 +41,7 @@ class InvoiceLine: else: type_ = self.invoice_type - if (self.product and type_ in ('in_invoice', 'in_credit_note') + if (self.product and type_ == 'in' and self.product.type == 'assets' and self.product.depreciable): self.account = self.product.account_asset_used diff --git a/purchase.py b/purchase.py index 2eab9b3c6f..f65aa96525 100644 --- a/purchase.py +++ b/purchase.py @@ -17,9 +17,8 @@ class PurchaseLine: 'an "Account Asset" on product "%s".'), }) - def get_invoice_line(self, invoice_type): - invoice_lines = super(PurchaseLine, self).get_invoice_line( - invoice_type) + def get_invoice_line(self): + invoice_lines = super(PurchaseLine, self).get_invoice_line() if (self.product and self.product.type == 'assets' and self.product.depreciable): diff --git a/tests/scenario_account_asset.rst b/tests/scenario_account_asset.rst index 8b53352ddb..2166c151a9 100644 --- a/tests/scenario_account_asset.rst +++ b/tests/scenario_account_asset.rst @@ -97,7 +97,7 @@ Buy an asset:: >>> Invoice = Model.get('account.invoice') >>> InvoiceLine = Model.get('account.invoice.line') - >>> supplier_invoice = Invoice(type='in_invoice') + >>> supplier_invoice = Invoice(type='in') >>> supplier_invoice.party = supplier >>> invoice_line = InvoiceLine() >>> supplier_invoice.lines.append(invoice_line) @@ -229,7 +229,7 @@ Create Moves for 3 other months:: Sale the asset:: - >>> customer_invoice = Invoice(type='out_invoice') + >>> customer_invoice = Invoice(type='out') >>> customer_invoice.party = customer >>> invoice_line = InvoiceLine() >>> customer_invoice.lines.append(invoice_line)