mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
intrastat_product: Add xml_attachment_id field
intrastat_product: add mail.activity.mixin and widget in form view product_harmonized_system: remove archive button (use Action menu) All modules: - use super() instead of super(class, self) - Update domain_force in multi-company ir.rule to v13 standard
This commit is contained in:
@@ -148,7 +148,7 @@ class IntrastatCommon(models.AbstractModel):
|
||||
_("Cannot delete the declaration %s " "because it is in Done state")
|
||||
% self.year_month
|
||||
)
|
||||
return super(IntrastatCommon, self).unlink()
|
||||
return super().unlink()
|
||||
|
||||
|
||||
class IntrastatResultView(models.TransientModel):
|
||||
|
||||
@@ -18,7 +18,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
_name = "intrastat.product.declaration"
|
||||
_description = "Intrastat Product Report Base Object"
|
||||
_rec_name = "year_month"
|
||||
_inherit = ["mail.thread", "intrastat.common"]
|
||||
_inherit = ["mail.thread", "mail.activity.mixin", "intrastat.common"]
|
||||
_order = "year_month desc, type, revision"
|
||||
_sql_constraints = [
|
||||
(
|
||||
@@ -32,7 +32,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super(IntrastatProductDeclaration, self).default_get(fields_list)
|
||||
res = super().default_get(fields_list)
|
||||
decl_date = fields.Date.context_today(self) - relativedelta(months=1)
|
||||
res.update(
|
||||
{"year": str(decl_date.year), "month": str(decl_date.month).rjust(2, "0")}
|
||||
@@ -150,6 +150,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
states={"done": [("readonly", True)]},
|
||||
)
|
||||
valid = fields.Boolean(compute="_compute_check_validity", string="Valid")
|
||||
xml_attachment_id = fields.Many2one("ir.attachment", string="XML Export")
|
||||
|
||||
@api.model
|
||||
def _default_company_id(self):
|
||||
@@ -225,7 +226,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
self.ensure_one()
|
||||
default = default or {}
|
||||
default["revision"] = self.revision + 1
|
||||
return super(IntrastatProductDeclaration, self).copy(default)
|
||||
return super().copy(default)
|
||||
|
||||
def _account_config_warning(self, msg):
|
||||
action = self.env.ref("account.action_account_config")
|
||||
@@ -805,6 +806,14 @@ class IntrastatProductDeclaration(models.Model):
|
||||
def generate_xml(self):
|
||||
""" generate the INTRASTAT Declaration XML file """
|
||||
self.ensure_one()
|
||||
if self.xml_attachment_id:
|
||||
raise UserError(
|
||||
_(
|
||||
"An XML Export already exists for %s. "
|
||||
"To re-generate it, you must first delete it."
|
||||
)
|
||||
% self.display_name
|
||||
)
|
||||
self.message_post(body=_("Generate XML Declaration File"))
|
||||
self._check_generate_xml()
|
||||
self._unlink_attachments()
|
||||
@@ -813,6 +822,7 @@ class IntrastatProductDeclaration(models.Model):
|
||||
attach_id = self._attach_xml_file(
|
||||
xml_string, "{}_{}".format(self.type, self.revision)
|
||||
)
|
||||
self.write({"xml_attachment_id": attach_id})
|
||||
return self._open_attach_view(attach_id)
|
||||
else:
|
||||
raise UserError(_("No XML File has been generated."))
|
||||
|
||||
@@ -19,7 +19,7 @@ class SaleOrder(models.Model):
|
||||
|
||||
def _prepare_invoice(self):
|
||||
"""Copy destination country to invoice"""
|
||||
vals = super(SaleOrder, self)._prepare_invoice()
|
||||
vals = super()._prepare_invoice()
|
||||
if self.intrastat_transport_id:
|
||||
vals["intrastat_transport_id"] = self.intrastat_transport_id.id
|
||||
if self.warehouse_id.region_id:
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
<field name="model_id" ref="model_intrastat_transaction" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
|
||||
</record>
|
||||
<record id="intrastat_region_company_rule" model="ir.rule">
|
||||
<field name="name">Intrastat Region Company rule</field>
|
||||
<field name="model_id" ref="model_intrastat_region" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
|
||||
</record>
|
||||
<record id="intrastat_product_declaration_company_rule" model="ir.rule">
|
||||
<field name="name">Intrastat Product Declaration Company rule</field>
|
||||
<field name="model_id" ref="model_intrastat_product_declaration" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
name="generate_xml"
|
||||
string="Generate XML Declaration File"
|
||||
type="object"
|
||||
attrs="{'invisible': [('state', '!=', 'draft')]}"
|
||||
attrs="{'invisible': [('xml_attachment_id', '!=', False)]}"
|
||||
invisible="context.get('generic_intrastat_product_declaration')"
|
||||
/>
|
||||
<button
|
||||
@@ -53,6 +53,10 @@
|
||||
<field name="year" />
|
||||
<field name="month" />
|
||||
<field name="type" />
|
||||
<field
|
||||
name="xml_attachment_id"
|
||||
invisible="context.get('generic_intrastat_product_declaration')"
|
||||
/>
|
||||
<field name="reporting_level" invisible="1" />
|
||||
</group>
|
||||
<group name="properties-2">
|
||||
@@ -115,6 +119,7 @@
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers" />
|
||||
<field name="activity_ids" widget="mail_activity" />
|
||||
<field name="message_ids" widget="mail_thread" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -99,9 +99,9 @@ class HSCode(models.Model):
|
||||
def create(self, vals):
|
||||
if vals.get("local_code"):
|
||||
vals["local_code"] = vals["local_code"].replace(" ", "")
|
||||
return super(HSCode, self).create(vals)
|
||||
return super().create(vals)
|
||||
|
||||
def write(self, vals):
|
||||
if vals.get("local_code"):
|
||||
vals["local_code"] = vals["local_code"].replace(" ", "")
|
||||
return super(HSCode, self).write(vals)
|
||||
return super().write(vals)
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
<field name="model_id" ref="model_hs_code" />
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -55,6 +55,13 @@
|
||||
<field name="model">hs.code</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="H.S. Code">
|
||||
<field name="active" invisible="1" />
|
||||
<widget
|
||||
name="web_ribbon"
|
||||
text="Archived"
|
||||
bg_color="bg-danger"
|
||||
attrs="{'invisible': [('active', '=', True)]}"
|
||||
/>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button
|
||||
class="oe_stat_button"
|
||||
@@ -82,18 +89,6 @@
|
||||
<span class="o_stat_text"> Products</span>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
name="toggle_active"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-archive"
|
||||
>
|
||||
<field
|
||||
name="active"
|
||||
widget="boolean_button"
|
||||
options='{"terminology": "archive"}'
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<group name="main">
|
||||
<field name="local_code" />
|
||||
|
||||
Reference in New Issue
Block a user