diff --git a/zero_quantity_account_move/__init__.py b/zero_quantity_account_move/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/zero_quantity_account_move/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/zero_quantity_account_move/__manifest__.py b/zero_quantity_account_move/__manifest__.py new file mode 100644 index 00000000000..c91aac517c2 --- /dev/null +++ b/zero_quantity_account_move/__manifest__.py @@ -0,0 +1,10 @@ +{ + 'name': 'Zero Accounting Approval', + 'description': 'Adding the zero quantity on account move line and If it is checked the quantity would be passed as 0 in einvoicing', + 'depends': ['l10n_in_edi'], + 'author': 'moahi', + 'data': [ + 'views/zero_views.xml', + ], + 'license': 'LGPL-3' +} diff --git a/zero_quantity_account_move/models/__init__.py b/zero_quantity_account_move/models/__init__.py new file mode 100644 index 00000000000..1e9f2573c1b --- /dev/null +++ b/zero_quantity_account_move/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_move_line +from . import zero_account_move diff --git a/zero_quantity_account_move/models/account_move_line.py b/zero_quantity_account_move/models/account_move_line.py new file mode 100644 index 00000000000..5b447327615 --- /dev/null +++ b/zero_quantity_account_move/models/account_move_line.py @@ -0,0 +1,7 @@ +from odoo import fields, models + + +class ZeroAccountMove(models.Model): + _inherit = 'account.move.line' + + zero_move = fields.Boolean(string="Is Zero Quantity", default=False) diff --git a/zero_quantity_account_move/models/zero_account_move.py b/zero_quantity_account_move/models/zero_account_move.py new file mode 100644 index 00000000000..195867d8cd1 --- /dev/null +++ b/zero_quantity_account_move/models/zero_account_move.py @@ -0,0 +1,13 @@ +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _get_l10n_in_edi_line_details(self, index, line, line_tax_details): + res = super()._get_l10n_in_edi_line_details(index, line, line_tax_details) + + if line.zero_move: + res['Qty'] = 0 + + return res diff --git a/zero_quantity_account_move/tests/__init__.py b/zero_quantity_account_move/tests/__init__.py new file mode 100644 index 00000000000..8617419e0a4 --- /dev/null +++ b/zero_quantity_account_move/tests/__init__.py @@ -0,0 +1 @@ +from . import test_zero diff --git a/zero_quantity_account_move/tests/test_zero.py b/zero_quantity_account_move/tests/test_zero.py new file mode 100644 index 00000000000..7c1792fbd39 --- /dev/null +++ b/zero_quantity_account_move/tests/test_zero.py @@ -0,0 +1,72 @@ +from odoo.tests.common import TransactionCase + + +class TestZeroQuantityEDI(TransactionCase): + + def setUp(self): + super().setUp() + + self.partner = self.env['res.partner'].create({ + 'name': 'Test Customer', + }) + + self.product = self.env['product.product'].create({ + 'name': 'Test Product', + 'type': 'consu', + 'list_price': 20, + }) + + def _get_tax_details(self): + return { + 'tax_details': {} + } + + def test_zero_quantity_in_edi(self): + + move = self.env['account.move'].create({ + 'move_type': 'out_invoice', + 'partner_id': self.partner.id, + }) + + self.env['account.move.line'].create({ + 'move_id': move.id, + 'product_id': self.product.id, + 'quantity': 9, + 'price_unit': 10, + 'zero_move': True, + 'name': 'Test line', + }) + + move.action_post() + line = move.invoice_line_ids[0] + + res = move._get_l10n_in_edi_line_details( + 1, line, self._get_tax_details() + ) + + self.assertEqual(res.get('Qty'), 0) + + def test_normal_quantity_in_edi(self): + + move = self.env['account.move'].create({ + 'move_type': 'out_invoice', + 'partner_id': self.partner.id, + }) + + self.env['account.move.line'].create({ + 'move_id': move.id, + 'product_id': self.product.id, + 'quantity': 5, + 'price_unit': 100, + 'zero_move': False, + 'name': 'Test line', + }) + + move.action_post() + line = move.invoice_line_ids[0] + + res = move._get_l10n_in_edi_line_details( + 1, line, self._get_tax_details() + ) + + self.assertEqual(res.get('Qty'), 5) diff --git a/zero_quantity_account_move/views/zero_views.xml b/zero_quantity_account_move/views/zero_views.xml new file mode 100644 index 00000000000..f0320ab80ff --- /dev/null +++ b/zero_quantity_account_move/views/zero_views.xml @@ -0,0 +1,16 @@ + + + + + account.move.form.inherit.zero.qty + account.move + + + + + + + + + +