diff --git a/account_invoice_margin/__manifest__.py b/account_invoice_margin/__manifest__.py index d0532353..b72b38eb 100644 --- a/account_invoice_margin/__manifest__.py +++ b/account_invoice_margin/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Account Invoice Margin", "summary": "Show margin in invoices", - "version": "15.0.1.0.1", + "version": "16.0.1.0.0", "category": "Account", "website": "https://github.com/OCA/margin-analysis", "author": "Tecnativa, " "GRAP, " "Odoo Community Association (OCA)", diff --git a/account_invoice_margin/readme/CONTRIBUTORS.rst b/account_invoice_margin/readme/CONTRIBUTORS.rst index a09fbab6..68fa8908 100644 --- a/account_invoice_margin/readme/CONTRIBUTORS.rst +++ b/account_invoice_margin/readme/CONTRIBUTORS.rst @@ -13,3 +13,7 @@ * `Avoin.Systems `__: * Nedas Žilinskas + +* `Factor Libre `__: + + * Luis J. Salvatierra diff --git a/account_invoice_margin/readme/DESCRIPTION.rst b/account_invoice_margin/readme/DESCRIPTION.rst index bd77a560..7042708e 100644 --- a/account_invoice_margin/readme/DESCRIPTION.rst +++ b/account_invoice_margin/readme/DESCRIPTION.rst @@ -2,10 +2,14 @@ This module allows to show sales margin in invoices. The new information is available: -* on the account form view +* on the invoice form view .. figure:: ../static/description/account_invoice_form.png + :scale: 80 % + :alt: Invoice Tree View -* and on the account tree view +* and on the invoice tree view .. figure:: ../static/description/account_invoice_tree.png + :scale: 80 % + :alt: Invoice Tree View diff --git a/account_invoice_margin/static/description/account_invoice_form_tree.png b/account_invoice_margin/static/description/account_invoice_tree.png similarity index 100% rename from account_invoice_margin/static/description/account_invoice_form_tree.png rename to account_invoice_margin/static/description/account_invoice_tree.png diff --git a/account_invoice_margin/tests/test_account_invoice_margin.py b/account_invoice_margin/tests/test_account_invoice_margin.py index 24d721f7..becdb95e 100644 --- a/account_invoice_margin/tests/test_account_invoice_margin.py +++ b/account_invoice_margin/tests/test_account_invoice_margin.py @@ -1,96 +1,34 @@ # © 2016 Sergio Teruel # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from odoo import fields -from odoo.tests.common import Form, TransactionCase, tagged +from odoo.tests.common import Form, tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon @tagged("post_install", "-at_install") -class TestAccountInvoiceMargin(TransactionCase): +class TestAccountInvoiceMargin(AccountTestInvoicingCommon): @classmethod def setUpClass(cls): super(TestAccountInvoiceMargin, cls).setUpClass() - cls.Product = cls.env["product.template"] - - cls.journal = cls.env["account.journal"].create( - {"name": "Test journal", "type": "sale", "code": "TEST_J"} - ) - cls.account_type = cls.env["account.account.type"].create( - {"name": "Test account type", "type": "other", "internal_group": "income"} - ) - cls.account = cls.env["account.account"].create( - { - "name": "Test account", - "code": "TEST_A", - "user_type_id": cls.account_type.id, - "reconcile": True, - } - ) - cls.partner = cls.env["res.partner"].create( - {"name": "Test partner", "customer_rank": 1, "is_company": True} - ) - cls.partner.property_account_receivable_id = cls.account - cls.product_categ = cls.env["product.category"].create( - {"name": "Test category"} - ) - - cls.product = cls.env["product.product"].create( - { - "name": "test product", - "categ_id": cls.product_categ.id, - "uom_id": cls.env.ref("uom.product_uom_unit").id, - "uom_po_id": cls.env.ref("uom.product_uom_unit").id, - "default_code": "test-margin", - "list_price": 200.00, - "standard_price": 100.00, - } - ) - cls.product.property_account_income_id = cls.account - cls.invoice = cls.env["account.move"].create( - { - "partner_id": cls.partner.id, - "invoice_date": fields.Date.from_string("2017-06-19"), - "move_type": "out_invoice", - "currency_id": cls.env.user.company_id.currency_id.id, - "invoice_line_ids": [ - ( - 0, - None, - { - "product_id": cls.product.id, - "product_uom_id": cls.product.uom_id.id, - "account_id": cls.product.property_account_income_id.id, - "name": "Test Margin", - "price_unit": cls.product.list_price, - "quantity": 10, - "purchase_price": cls.product.standard_price, - }, - ) - ], - } + cls.product_a.lst_price = 200 + cls.product_a.standard_price = 100 + cls.invoice = cls.init_invoice( + "out_invoice", + partner=cls.partner_a, + invoice_date=fields.Date.from_string("2017-06-19"), + post=False, + products=cls.product_a, ) - cls.vendor_bill = cls.env["account.move"].create( - { - "partner_id": cls.partner.id, - "invoice_date": fields.Date.from_string("2017-06-19"), - "move_type": "in_invoice", - "currency_id": cls.env.user.company_id.currency_id.id, - "invoice_line_ids": [ - ( - 0, - None, - { - "product_id": cls.product.id, - "product_uom_id": cls.product.uom_id.id, - "account_id": cls.product.property_account_income_id.id, - "name": "Test Margin", - "price_unit": cls.product.list_price, - "quantity": 10, - }, - ) - ], - } + cls.invoice.invoice_line_ids.quantity = 10 + cls.vendor_bill = cls.init_invoice( + "in_invoice", + partner=cls.partner_a, + invoice_date=fields.Date.from_string("2017-06-19"), + post=False, + products=cls.product_a, ) + cls.vendor_bill.invoice_line_ids.quantity = 10 def test_invoice_margin(self): self.assertEqual(self.invoice.invoice_line_ids.purchase_price, 100.00) @@ -108,7 +46,6 @@ def test_vendor_bill_margin(self): def test_invoice_margin_uom(self): inv_line = self.invoice.invoice_line_ids inv_line.update({"product_uom_id": self.env.ref("uom.product_uom_dozen").id}) - inv_line.with_context(check_move_validity=False)._onchange_uom_id() self.assertEqual(inv_line.margin, 12000.00) def test_invoice_refund(self): @@ -148,10 +85,10 @@ def test_invoice_different_currency(self): move_form = Form( self.env["account.move"].with_context(default_move_type="out_invoice") ) - move_form.partner_id = self.partner + move_form.partner_id = self.partner_a move_form.currency_id = currency move_form.invoice_date = "2022-01-01" with move_form.invoice_line_ids.new() as line_form: - line_form.product_id = self.product + line_form.product_id = self.product_a invoice = move_form.save() self.assertEqual(invoice.invoice_line_ids.purchase_price, 200) diff --git a/account_invoice_margin/views/account_invoice_margin_view.xml b/account_invoice_margin/views/account_invoice_margin_view.xml index 466dac1c..d640de73 100644 --- a/account_invoice_margin/views/account_invoice_margin_view.xml +++ b/account_invoice_margin/views/account_invoice_margin_view.xml @@ -5,55 +5,74 @@ account.move - - - - - - - - - - + + + - - - + + + - - - + + + account.move - - - + +