Skip to content

Commit 00fbd20

Browse files
committed
[ADD] l10n_it_intrastat: aggiunto paese di origine su prodotto e categoria
1 parent 3234301 commit 00fbd20

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

l10n_it_intrastat/models/account.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,18 @@ def _prepare_intrastat_line_country_good_origin(self, res):
152152

153153
def _prepare_intrastat_line_country_origin(self, res):
154154
self.ensure_one()
155-
country_origin_id = self.env["res.country"].browse()
156-
if self.move_id.is_sale_document():
157-
country_origin_id = self.move_id.company_id.partner_id.country_id
158-
elif self.move_id.is_purchase_document():
159-
country_origin_id = self.move_id.partner_id.country_id
155+
if self.mapped("product_id.product_tmpl_id.intrastat_origin_country_id"):
156+
country_origin_id = (
157+
self.product_id.product_tmpl_id.intrastat_origin_country_id
158+
)
159+
elif self.mapped(
160+
"product_id.product_tmpl_id.categ_id.intrastat_origin_country_id"
161+
):
162+
country_origin_id = (
163+
self.product_id.product_tmpl_id.categ_id.intrastat_origin_country_id
164+
)
165+
else:
166+
country_origin_id = self.env["res.country"].browse()
160167
res.update({"country_origin_id": country_origin_id.id})
161168

162169
def _prepare_intrastat_line_delivery(self, company_id, res):

l10n_it_intrastat/models/product.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class ProductCategory(models.Model):
1010
intrastat_code_id = fields.Many2one(
1111
"report.intrastat.code", string="Nomenclature Code"
1212
)
13+
intrastat_origin_country_id = fields.Many2one(
14+
"res.country", string="Origin Country"
15+
)
1316
intrastat_type = fields.Selection(
1417
[
1518
("good", "Goods"),
@@ -27,6 +30,9 @@ class ProductTemplate(models.Model):
2730
intrastat_code_id = fields.Many2one(
2831
comodel_name="report.intrastat.code", string="Intrastat Code"
2932
)
33+
intrastat_origin_country_id = fields.Many2one(
34+
"res.country", string="Origin Country"
35+
)
3036
intrastat_type = fields.Selection(
3137
selection=[
3238
("good", "Goods"),
@@ -44,12 +50,20 @@ def get_intrastat_data(self):
4450
- Intrastat Code on product template
4551
- Intrastat Code on product category
4652
"""
47-
res = {"intrastat_code_id": False, "intrastat_type": False}
53+
res = {
54+
"intrastat_code_id": False,
55+
"intrastat_origin_country_id": False,
56+
"intrastat_type": False,
57+
}
4858
# From Product
4959
if self.intrastat_type:
5060
res["intrastat_code_id"] = self.intrastat_code_id.id
61+
res["intrastat_origin_country_id"] = self.intrastat_origin_country_id.id
5162
res["intrastat_type"] = self.intrastat_type
5263
elif self.categ_id and self.categ_id.intrastat_code_id:
5364
res["intrastat_code_id"] = self.categ_id.intrastat_code_id.id
65+
res[
66+
"intrastat_origin_country_id"
67+
] = self.categ_id.intrastat_origin_country_id.id
5468
res["intrastat_type"] = self.categ_id.intrastat_type
5569
return res

l10n_it_intrastat/views/product.xml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
attrs="{'invisible':[('intrastat_type','!=', 'good'),('intrastat_type','!=', 'service')],
1818
'required':[('intrastat_type','in', ['good', 'service'])]}"
1919
/>
20+
<field name="intrastat_origin_country_id" />
2021
</group>
2122

2223
</group>
@@ -38,6 +39,7 @@
3839
attrs="{'invisible':[('intrastat_type','!=', 'good'),('intrastat_type','!=', 'service')],
3940
'required':[('intrastat_type','in', ['good', 'service'])]}"
4041
/>
42+
<field name="intrastat_origin_country_id" />
4143
</group>
4244
</group>
4345
</xpath>

0 commit comments

Comments
 (0)