我想计算与卖家相关的销售额,我使用了len和search_count,但该方法对我不起作用。我目前有一个称为文件的表格,可以在其中买卖产品。因此,我希望他只告诉我我所做的销售,而不要购买。使用len时,他会告诉我有关购买和销售的信息,因此这对我不起作用。 代码如下:
class Document (models.Model):
total_document_sales = fields.Float (string = "Total sale")
class Seller (models.Model):
sales_counter = fields.Integer (string = "Sales made",compute = "get_sales_realized")
document_ids = fields.One2many (asdel_name = 'project_rc.document',inverse_name = 'worker_id',string = 'Invoice')
##The method using the len is as follows:
def get_sales_realized (self):
for rec in self:
rec.sales_counter = len (rec.document_ids.total_document_sales)
##The method using the search_count is as follows:##
@api.depends (document_ids)
def get_sales_realized (self):
count = self.env ['project_rc.document.ids']. search_count ([('total_document_sales','=',self.document.ids.total_document_sales)])
self.sales_counter = count
但我都找不到。请帮助我。