在这里,我需要在crm机会方面的实际销售。
我已完成所有计算部分,但不存储该值
track_visibility='always'
和store=True
。
from odoo import api,fields,models,_
class CrmLead(models.Model):
_inherit = "crm.lead"
actual_sales = fields.Float(string="Actual Sales", store=True, compute="compute_actual_sales", track_visibility='always')
@api.depends('order_ids')
def compute_actual_sales(self):
for record in self:
total_actual_sales_amount_in_opp = 0
for order in record.order_ids:
if order.state == 'sale':
sales_amount_in_opp = order.amount_total
print">>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<sales_amount_in_opp>>>>>>>>>>>>>>><", sales_amount_in_opp
total_actual_sales_amount_in_opp = order.amount_total + total_actual_sales_amount_in_opp
print">>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<total_sales_amount_in_opp>>>>>>>>>>>>>>><", total_actual_sales_amount_in_opp
record.actual_sales = total_actual_sales_amount_in_opp