[IMP] Add buttons product and product templates for analytic rules
This commit is contained in:
parent
32dd003d60
commit
739a1d0051
|
@ -130,4 +130,26 @@ class product_product(osv.Model):
|
|||
'rules_count': fields.function(_rules_count, string='# Analytic Rules', type='integer'),
|
||||
}
|
||||
|
||||
class product_template(osv.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
def _rules_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
Analytic = self.pool['account.analytic.default']
|
||||
res = {}
|
||||
for product_tmpl_id in self.browse(cr, uid, ids):
|
||||
res[product_tmpl_id.id] = sum([p.rules_count for p in product_tmpl_id.product_variant_ids])
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'rules_count': fields.function(_rules_count, string='# Analytic Rules', type='integer'),
|
||||
}
|
||||
|
||||
|
||||
def action_view_rules(self, cr, uid, ids, context=None):
|
||||
products = self._get_products(cr, uid, ids, context=context)
|
||||
result = self._get_act_window_dict(cr, uid, 'account_analytic_default','action_product_default_list', context=context)
|
||||
result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]"
|
||||
result['context'] = "{}"
|
||||
return result
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -88,6 +88,20 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="product_template_view_default_analytic_button">
|
||||
<field name="name">product.template.stock.move</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='buttons']" position="inside">
|
||||
<button class="oe_inline oe_stat_button" name= "action_view_rules" type="object"
|
||||
groups="analytic.group_analytic_accounting" icon="fa-xing">
|
||||
<field string="Analytic Rules" name="rules_count" widget="statinfo" />
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window
|
||||
name="Entries"
|
||||
id="act_account_acount_move_line_open"
|
||||
|
|
Loading…
Reference in New Issue