Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, fields, models
from odoo import Command, _, api, fields, models
from odoo.exceptions import ValidationError


class AccountProductFiscalClassification(models.Model):
_name = "account.product.fiscal.classification"
_description = "Fiscal Classification"
_order = "name"
_inherit = ["mail.activity.mixin", "mail.thread"]

name = fields.Char(required=True)
name = fields.Char(required=True, tracking=True)

description = fields.Text()

active = fields.Boolean(
default=True,
tracking=True,
help="If unchecked, it will allow you to hide the Fiscal"
" Classification without removing it.",
)

company_id = fields.Many2one(
comodel_name="res.company",
string="Company",
tracking=True,
help="Specify a company"
" if you want to define this Fiscal Classification only for specific"
" company. Otherwise, this Fiscal Classification will be available"
Expand All @@ -46,6 +49,7 @@ class AccountProductFiscalClassification(models.Model):
column1="fiscal_classification_id",
column2="tax_id",
string="Purchase Taxes",
tracking=True,
domain="""[
('type_tax_use', 'in', ['purchase', 'all'])]""",
)
Expand All @@ -56,6 +60,7 @@ class AccountProductFiscalClassification(models.Model):
column1="fiscal_classification_id",
column2="tax_id",
string="Sale Taxes",
tracking=True,
domain="""[
('type_tax_use', 'in', ['sale', 'all'])]""",
)
Expand Down Expand Up @@ -107,6 +112,28 @@ def unlink(self):
)
return super().unlink()

def _mail_track(self, tracked_fields, initial_values):
changes, tracking_value_ids = super()._mail_track(
tracked_fields, initial_values
)
# Many2many tracking
if len(changes) > len(tracking_value_ids):
for changed_field in changes:
if tracked_fields[changed_field]["type"] in ["one2many", "many2many"]:
field = self.env["ir.model.fields"]._get(self._name, changed_field)
vals = {
"field": field.id,
"field_desc": field.field_description,
"field_type": field.ttype,
"tracking_sequence": field.tracking,
"old_value_char": ", ".join(
initial_values[changed_field].mapped("name")
),
"new_value_char": ", ".join(self[changed_field].mapped("name")),
}
tracking_value_ids.append(Command.create(vals))
return changes, tracking_value_ids

# Custom Sections
@api.model
def _prepare_vals_from_taxes(self, purchase_taxes, sale_taxes):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" />
<field name="activity_ids" />
<field name="message_ids" />
</div>
</form>
</field>
</record>
Expand Down