Skip to content

Commit

Permalink
adaugare versiuni in intrastat
Browse files Browse the repository at this point in the history
  • Loading branch information
dhongu committed Oct 6, 2023
1 parent 40c2dc2 commit 5b8fd48
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 24 deletions.
2 changes: 1 addition & 1 deletion l10n_ro_intrastat_xml/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Romanian Intrastat Declaration XML",
"license": "AGPL-3",
"version": "15.0.1.0.2",
"version": "15.0.1.0.3",
"author": "Dorin Hongu," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-romania",
"depends": ["product", "sale_stock", "account", "l10n_ro"],
Expand Down
94 changes: 82 additions & 12 deletions l10n_ro_intrastat_xml/wizard/intrastat_xml_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,46 @@ def _get_def_month(self):
def _get_def_year(self):
return self._get_def_monthyear()[0]

def _get_country_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.country_ver", default="2021")

def _get_eu_country_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.eu_country_ver", default="2021")

def _get_cn8(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.cn8", default="2023")

def _get_mode_of_transport_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.mode_of_transport_ver", default="2005")

def _get_delivery_terms_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.delivery_terms_ver", default="2021")

def _get_nature_of_transaction_a_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.nature_of_transaction_a_ver", default="2010")

def _get_nature_of_transaction_b_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.nature_of_transaction_b_ver", default="2010")

def _get_county_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.county_ver", default="1")

def _get_locality_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.locality_ver", default="06/2006")

def _get_unit_ver(self):
get_param = self.env["ir.config_parameter"].sudo().get_param
return get_param("l10n_ro_intrastat_xml.unit_ver", default="1")

name = fields.Char("File Name", default="intrastat.xml")
month = fields.Selection(
[
Expand Down Expand Up @@ -62,7 +102,24 @@ def _get_def_year(self):
contact_id = fields.Many2one("res.partner", "Contact", domain=[("is_company", "=", False)], required=True)
file_save = fields.Binary("Intrastat Report File", readonly=True)
state = fields.Selection([("draft", "Draft"), ("download", "Download")], string="State", default="draft")
cn8 = fields.Char("CN8", size=4, required=True, default="2022")

display_versions = fields.Boolean("Display Versions", default=False)
cn8 = fields.Char("CN8", size=4, required=True, default=_get_cn8)

country_ver = fields.Char("CountryVer", size=4, required=True, default=_get_country_ver)
eu_country_ver = fields.Char("EuCountryVer", size=4, required=True, default=_get_eu_country_ver)
mode_of_transport_ver = fields.Char("ModeOfTransportVer", size=4, required=True, default=_get_mode_of_transport_ver)
delivery_terms_ver = fields.Char("DeliveryTermsVer", size=4, required=True, default=_get_delivery_terms_ver)
nature_of_transaction_a_ver = fields.Char(
"NatureOfTransactionAVer", size=4, required=True, default=_get_nature_of_transaction_a_ver
)
nature_of_transaction_b_ver = fields.Char(
"NatureOfTransactionBVer", size=4, required=True, default=_get_nature_of_transaction_b_ver
)
county_ver = fields.Char("CountyVer", size=4, required=True, default=_get_county_ver)
locality_ver = fields.Char("LocalityVer", size=4, required=True, default=_get_locality_ver)
unit_ver = fields.Char("UnitVer", size=4, required=True, default=_get_unit_ver)

enterprise = fields.Boolean("Enterprise", default=False, compute="_compute_enterprise")

def _compute_enterprise(self):
Expand All @@ -85,6 +142,19 @@ def create_xml(self):
:return: Value for next action.
:rtype: dict
"""

set_param = self.env["ir.config_parameter"].sudo().set_param
set_param("l10n_ro_intrastat_xml.country_ver", self.country_ver)
set_param("l10n_ro_intrastat_xml.eu_country_ver", self.eu_country_ver)
set_param("l10n_ro_intrastat_xml.cn8", self.cn8)
set_param("l10n_ro_intrastat_xml.mode_of_transport_ver", self.mode_of_transport_ver)
set_param("l10n_ro_intrastat_xml.delivery_terms_ver", self.delivery_terms_ver)
set_param("l10n_ro_intrastat_xml.nature_of_transaction_a_ver", self.nature_of_transaction_a_ver)
set_param("l10n_ro_intrastat_xml.nature_of_transaction_b_ver", self.nature_of_transaction_b_ver)
set_param("l10n_ro_intrastat_xml.county_ver", self.county_ver)
set_param("l10n_ro_intrastat_xml.locality_ver", self.locality_ver)
set_param("l10n_ro_intrastat_xml.unit_ver", self.unit_ver)

decl_datas = self
company = self.env.user.company_id
if not (company.partner_id and company.partner_id.country_id and company.partner_id.country_id.id):
Expand All @@ -108,25 +178,25 @@ def create_xml(self):

CodeVersion = ET.SubElement(decl, "InsCodeVersions")
tag = ET.SubElement(CodeVersion, "CountryVer")
tag.text = "2021"
tag.text = self.country_ver
tag = ET.SubElement(CodeVersion, "EuCountryVer")
tag.text = "2021"
tag.text = self.eu_country_ver
tag = ET.SubElement(CodeVersion, "CnVer")
tag.text = decl_datas.cn8
tag.text = self.cn8
tag = ET.SubElement(CodeVersion, "ModeOfTransportVer")
tag.text = "2005"
tag.text = self.mode_of_transport_ver
tag = ET.SubElement(CodeVersion, "DeliveryTermsVer")
tag.text = "2021"
tag.text = self.delivery_terms_ver
tag = ET.SubElement(CodeVersion, "NatureOfTransactionAVer")
tag.text = "2010"
tag.text = self.nature_of_transaction_a_ver
tag = ET.SubElement(CodeVersion, "NatureOfTransactionBVer")
tag.text = "2010"
tag.text = self.nature_of_transaction_b_ver
tag = ET.SubElement(CodeVersion, "CountyVer")
tag.text = "1"
tag.text = self.county_ver
tag = ET.SubElement(CodeVersion, "LocalityVer")
tag.text = "06/2006"
tag.text = self.locality_ver
tag = ET.SubElement(CodeVersion, "UnitVer")
tag.text = "1"
tag.text = self.unit_ver

# Add Administration elements
header = ET.SubElement(decl, "InsDeclarationHeader")
Expand Down Expand Up @@ -185,7 +255,7 @@ def _get_lines(self, decl_datas, dispatchmode, decl):
company = self.env.user.company_id

mode1 = "out_invoice" if dispatchmode else "in_invoice"
mode2 = "in_refund" if dispatchmode else "out_refund"
mode2 = "out_refund" if dispatchmode else "in_refund"

entries = []
# care sunt liniile de facturi relevante pentru delcaratia de intrastat
Expand Down
31 changes: 20 additions & 11 deletions l10n_ro_intrastat_xml/wizard/l10n_ro_intrastat_xml_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,23 @@
<field name="contact_id" />
</group>
<group>
<field name="display_versions" />
</group>
</group>
<group states="draft">
<group attrs="{'invisible': [('display_versions', '=', False)]}">
<field name="cn8" />
<field name="country_ver" />
<field name="eu_country_ver" />
<field name="mode_of_transport_ver" />
<field name="delivery_terms_ver" />
</group>
<group attrs="{'invisible': [('display_versions', '=', False)]}">
<field name="nature_of_transaction_a_ver" />
<field name="nature_of_transaction_b_ver" />
<field name="county_ver" />
<field name="locality_ver" />
<field name="unit_ver" />
</group>
</group>
<div states="download">
Expand Down Expand Up @@ -52,27 +68,20 @@
<field name="target">new</field>
</record>

<!-- <act_window-->
<!-- id="action_intrastat_xml_declaration"-->
<!-- name="Intrastat Declaration"-->
<!-- res_model="intrastat_xml_declaration"-->
<!-- view_mode="form"-->
<!-- view_id="view_intrastat_declaration_xml"-->
<!-- target="new"-->
<!-- />-->

<menuitem
id="menu_intrastat"
name="Intrastat"
parent="account.menu_finance_reports"
groups="account.group_account_manager"
parent="account.menu_finance_entries"
groups="account.group_account_invoice"
/>

<menuitem
name="Intrastat Declaration"
parent="menu_intrastat"
action="action_intrastat_xml_declaration"
id="l10n_ro_intrastat_xml_declaration"
groups="account.group_account_manager"
groups="account.group_account_invoice"
/>
</data>
</odoo>

0 comments on commit 5b8fd48

Please sign in to comment.