mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
@@ -491,7 +491,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
notedict["partner"][partner.display_name][msg].add(
|
||||
notedict["inv_origin"]
|
||||
)
|
||||
else:
|
||||
elif inv.fiscal_position_id.intrastat != "b2c":
|
||||
msg = _("Missing <em>VAT Number</em>")
|
||||
notedict["partner"][partner.display_name][msg].add(
|
||||
notedict["inv_origin"]
|
||||
|
||||
@@ -41,6 +41,11 @@ class IntrastatProductCommon(IntrastatCommon):
|
||||
"vat_required": True,
|
||||
}
|
||||
cls.position = cls.position_obj.create(vals)
|
||||
vals_b2c = {
|
||||
"name": "Intrastat Fiscal Position B2C",
|
||||
"intrastat": "b2c",
|
||||
}
|
||||
cls.position_b2c = cls.position_obj.create(vals_b2c)
|
||||
|
||||
@classmethod
|
||||
def _init_regions(cls):
|
||||
|
||||
@@ -55,6 +55,9 @@ class IntrastatSaleCommon(IntrastatProductCommon):
|
||||
if vals is not None:
|
||||
values.update(vals)
|
||||
cls.customer = cls.partner_obj.create(values)
|
||||
values.pop("vat")
|
||||
values["property_account_position_id"] = cls.position_b2c.id
|
||||
cls.customer_no_vat = cls.partner_obj.create(values)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -63,9 +66,9 @@ class IntrastatSaleCommon(IntrastatProductCommon):
|
||||
cls._init_customer()
|
||||
|
||||
@classmethod
|
||||
def _create_sale_order(cls, vals=None):
|
||||
def _create_sale_order(cls, partner, vals=None):
|
||||
vals = {
|
||||
"partner_id": cls.customer.id,
|
||||
"partner_id": partner.id,
|
||||
}
|
||||
sale_new = cls.sale_obj.new(vals)
|
||||
sale_vals = sale_new._convert_to_write(sale_new._cache)
|
||||
|
||||
@@ -11,7 +11,7 @@ class TestIntrastatProductSale(IntrastatSaleCommon):
|
||||
"""Tests for this module"""
|
||||
|
||||
def test_sale_to_invoice_default(self):
|
||||
self._create_sale_order()
|
||||
self._create_sale_order(self.customer)
|
||||
self.sale.action_confirm()
|
||||
self.sale.picking_ids.action_assign()
|
||||
for line in self.sale.picking_ids.move_line_ids:
|
||||
@@ -30,7 +30,7 @@ class TestIntrastatProductSale(IntrastatSaleCommon):
|
||||
|
||||
# Test specific transport set on sale to invoice
|
||||
def test_sale_to_invoice(self):
|
||||
self._create_sale_order()
|
||||
self._create_sale_order(self.customer)
|
||||
# Set intrastat transport mode to rail
|
||||
self.sale.intrastat_transport_id = self.transport_rail
|
||||
self.sale.action_confirm()
|
||||
@@ -53,7 +53,7 @@ class TestIntrastatProductSale(IntrastatSaleCommon):
|
||||
date_order = "2021-09-01"
|
||||
declaration_date = "2021-10-01"
|
||||
with freeze_time(date_order):
|
||||
self._create_sale_order()
|
||||
self._create_sale_order(self.customer)
|
||||
# Set intrastat transport mode to rail
|
||||
self.sale.intrastat_transport_id = self.transport_rail
|
||||
self.sale.action_confirm()
|
||||
@@ -87,6 +87,37 @@ class TestIntrastatProductSale(IntrastatSaleCommon):
|
||||
file_data = self._create_xls()
|
||||
self.check_xls(file_data[0])
|
||||
|
||||
def test_sale_declaration_b2c_no_vat(self):
|
||||
date_order = "2021-09-01"
|
||||
declaration_date = "2021-10-01"
|
||||
with freeze_time(date_order):
|
||||
self._create_sale_order(self.customer_no_vat)
|
||||
# Set intrastat transport mode to rail
|
||||
self.sale.intrastat_transport_id = self.transport_rail
|
||||
self.sale.action_confirm()
|
||||
self.sale.picking_ids.action_assign()
|
||||
for line in self.sale.picking_ids.move_line_ids:
|
||||
line.qty_done = line.reserved_uom_qty
|
||||
self.sale.picking_ids._action_done()
|
||||
self.assertEqual("done", self.sale.picking_ids.state)
|
||||
|
||||
with freeze_time(date_order):
|
||||
invoice = self.sale._create_invoices()
|
||||
invoice.action_post()
|
||||
|
||||
# Check if transport mode has been transmitted to invoice
|
||||
self.assertEqual(
|
||||
self.transport_rail,
|
||||
invoice.intrastat_transport_id,
|
||||
)
|
||||
vals = {
|
||||
"declaration_type": "dispatches",
|
||||
}
|
||||
with freeze_time(declaration_date):
|
||||
self._create_declaration(vals)
|
||||
self.declaration.action_gather()
|
||||
self.assertFalse(self.declaration.note)
|
||||
|
||||
|
||||
class TestIntrastatProductSaleCase(TestIntrastatProductSale, TransactionCase):
|
||||
"""Test Intrastat Sale"""
|
||||
|
||||
Reference in New Issue
Block a user