The computer to calculate the amount of each beef automatically does not work

I have a problem with 2 modules in Odoo, the first is my auxiliary module that stores the price per kilo of each beef:

from odoo import api, fields, models

class LivestockPrice(models.Model):
 _inherit = ['mail.thread', 'mail.activity.mixin']
 _name = 'price.pound'
 _description = "New pound price"
 _order = 'date_pound desc'

 name = fields.Char(string="New")
 active = fields.Boolean(string="Active", default=True)
 cow_id = fields.Many2one(
 'livestock.model',
 string="Beef identifier",
 required=True
 )
date_pound = fields.Date(
 string="New price date",
 required=True,
 default=fields.Date.today()
 )
 price_import = fields.Monetary(string="Price per kilo", required=True, tracking=True)
 type_cow = fields.Selection(
 related='cow_id.type_cow',
 string="Type of livestock",
 readonly=False,
 store=True,
 required=True
 )

What I want is to record prices per pound on a certain date and according to the type of cattle, that is, it stores several prices per pound according to the type_cow, now, this is my main model:

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


class LivestockModel(models.Model):

 _name = 'livestock.model'
 _inherit = ['mail.thread', 'mail.activity.mixin']
 _description = 'New cattle from the agricultural and livestock farm created'
 _order = 'date_create desc'
 _rec_name = 'cow_id'
 _order = 'cow_id asc'
 cow_id = fields.Char(
 required=True,
 string="Beef identifier",
 tracking=True
 )
 weight_cow = fields.Float(
 string="Current weight",
 tracking=True,
 store=True
 )
 other_model = fields.Many2one('price.pound', string="Price per pound")
 price_actually = fields.Monetary(
 compute="_compute_price_actually",
 string="Current price per kilo",
 store=True
 )
 price_import = fields.Monetary(
 related="other_model.price_import",
 string="Price per kilo",
 store=True
 )
 price_total = fields.Monetary(
 compute="_compute_cost_import",
 string="Amount",
 store=True
 )
 type_cow = fields.Selection([
 ('Steer', 'Steer of meat'),
 ('Heifer', 'Beef Heifer')
 ], string="Type of livestock:", required=True)
 @api.depends('weight_cow', 'other_model.price_import')
 def _compute_cost_import(self):
 """This function calculates the amount of each beef"""
 for record in self:
 price_import_record = self.env['price.pound'].search(
 [('type_cow', '=', record.type_cow)], order='date_pound desc', limit=1)
 if record.weight_cow and price_import_record:
 record.price_total = record.weight_cow * price_import_record.price_import
 else:
 record.price_total = 0.0 

As you can see, in my livestock.model I use my own type_cow for that model, what I am looking for is to calculate the amount for each cow according to the type of livestock, which is type_cow, but I have a problem, it does it but only when I enter a new peso, which it shouldn’t be, because it should be calculated automatically when I enter a new price per pound or a new peso. You must do the calculation whenever a new price_import or weight record is introduced in that model.

New contributor

Delvis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật