[FIX] purchase, sale: Confirmed sale
The number displayed in the Sales button shows the number of sale order lines confirmed for the current product. The number displayed in the Purchases button shows the number of purchase order lines for the current product. closes:#7107
This commit is contained in:
@@ -1649,9 +1649,9 @@ class product_product(osv.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def _purchase_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
Purchase = self.pool['purchase.order']
|
||||
Purchase = self.pool['purchase.order.line']
|
||||
return {
|
||||
product_id: Purchase.search_count(cr,uid, [('order_line.product_id', '=', product_id)], context=context)
|
||||
product_id: Purchase.search_count(cr,uid, [('product_id', '=', product_id)], context=context)
|
||||
for product_id in ids
|
||||
}
|
||||
|
||||
|
||||
+5
-8
@@ -1169,14 +1169,11 @@ class product_product(osv.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def _sales_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
r = dict.fromkeys(ids, 0)
|
||||
domain = [
|
||||
('state', 'in', ['waiting_date','progress','manual', 'shipping_except', 'invoice_except', 'done']),
|
||||
('product_id', 'in', ids),
|
||||
]
|
||||
for group in self.pool['sale.report'].read_group(cr, uid, domain, ['product_id','product_uom_qty'], ['product_id'], context=context):
|
||||
r[group['product_id'][0]] = group['product_uom_qty']
|
||||
return r
|
||||
sale = self.pool['sale.order.line']
|
||||
return {
|
||||
product_id: sale.search_count(cr, uid, [('product_id', '=', product_id), ('state', 'in', ['waiting_date', 'progress', 'manual', 'shipping_except', 'invoice_except', 'confirmed', 'done'])], context=context)
|
||||
for product_id in ids
|
||||
}
|
||||
|
||||
def action_view_sales(self, cr, uid, ids, context=None):
|
||||
result = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'sale.action_order_line_product_tree', raise_if_not_found=True)
|
||||
|
||||
@@ -512,7 +512,7 @@
|
||||
<search string="Search Sales Order">
|
||||
<filter icon="terp-dolar_ok!" string="To Invoice" domain="[('invoiced','<>', 1),('state','=','done')]" help="Sales Order Lines ready to be invoiced"/>
|
||||
<separator/>
|
||||
<filter string="Confirmed" domain="[('state', 'in', ['waiting_date','progress','manual', 'shipping_except', 'invoice_except', 'done'])]" name="confirmed"/>
|
||||
<filter string="Confirmed" domain="[('state', 'in', ['waiting_date','progress','manual', 'shipping_except', 'invoice_except', 'confirmed', 'done'])]" name="confirmed"/>
|
||||
<separator/>
|
||||
<filter string="My Sales Order Lines" icon="terp-personnal" domain="[('salesman_id','=',uid)]" help="Sales Order Lines related to a Sales Order of mine"/>
|
||||
<field name="order_id"/>
|
||||
|
||||
Reference in New Issue
Block a user