diff --git a/models/supplies_cost.py b/models/supplies_cost.py index df30ac9511615b0d3549a4025e957d7bef641835..3c14a9f57417f24657b4f74f6608fd915f7bfa78 100644 --- a/models/supplies_cost.py +++ b/models/supplies_cost.py @@ -25,7 +25,7 @@ class SuppliesCost(models.Model): show_product_id = fields.Boolean(default=False) calculated_cost = fields.Float( - "$/Kg o Un", compute="_compute_calculated_cost", store=True + "$/Kg o Un", store=True ) price = fields.Float(required=True) uom_id = fields.Many2one("uom.uom", related="product_id.uom_id", readonly=True) @@ -77,7 +77,6 @@ class SuppliesCost(models.Model): } } - @api.depends("price", "cost_lost", "currency_id", "freight_plus_others") def _compute_calculated_cost(self): """Computes calculated_cost field. Through converted_price it takes the inputted price and converts it to @@ -100,6 +99,7 @@ class SuppliesCost(models.Model): and record.calculated_cost > 0 ): record.last_update_price = record.calculated_cost + self.create_historical_record() record.calculated_cost = price_per_kg if record.last_update_price > 0: variation = ( @@ -130,10 +130,10 @@ class SuppliesCost(models.Model): if self.calculated_cost > 0: hist_id = self.env["historical.prices"].create(hist_values) - @api.onchange("calculated_cost") - def onchange_calculated_cost(self): - """Function that triggers everytime calculated_cost is modified or recalculated.""" - self.create_historical_record() + # @api.onchange("calculated_cost") + # def onchange_calculated_cost(self): + # """Function that triggers everytime calculated_cost is modified or recalculated.""" + # self.create_historical_record() @api.depends("product_id", "price", "calculated_cost", "partner_ids") def _compute_last_update_date(self): diff --git a/views/supplies_cost.xml b/views/supplies_cost.xml index f3fd3b5e116e72d6406057877aa42bd6e0e51d3d..5b8f2b2fb738aaa40dba1920086f96732a8f8a98 100644 --- a/views/supplies_cost.xml +++ b/views/supplies_cost.xml @@ -7,6 +7,19 @@ <field name="view_mode">tree,form</field> </record> + <record id="supplies_cost_view_search" model="ir.ui.view"> + <field name="name">supplies.cost.filter</field> + <field name="model">supplies.cost</field> + <field name="arch" type="xml"> + <search string="Search"> + <field name="product_id"/> + <field name="partner_ids" /> + <field name="category_id" /> + <separator /> + </search> + </field> + </record> + <record id="supplies_cost_tree" model="ir.ui.view"> <field name="name">supplies.cost.tree</field> <field name="model">supplies.cost</field> @@ -28,7 +41,7 @@ <field name="freight_plus_others" optional="show" force_save="1" attrs="{'readonly': [('show_freight_value','=', True)]}" /> <field name="cost_lost" optional="show" /> - <field name="partner_ids" widget="many2many_tags" optional="show" string="Prov." /> + <field name="partner_ids" widget="many2many_tags" optional="show" string="Prov." domain="[('supplier_rank', '>', 0)]"/> <field name="last_update_price" optional="show" readonly="1" /> <field name="variation_percentage" optional="show" readonly="1" decoration-danger="red_text" decoration-bf="red_text"/> <button name="acknowledge_alert" type="object" string="Ap. Alerta"/> @@ -51,4 +64,4 @@ </field> </record> -</odoo> \ No newline at end of file +</odoo>