Commit 19d6332f authored by Sebastian Kennedy's avatar Sebastian Kennedy
Browse files

Adaptacion product_template v8

parent 61d053c1
Branches
No related merge requests found
Showing with 57 additions and 4 deletions
......@@ -27,15 +27,14 @@
"description": """
""",
'website': 'http://www.e-mips.com.ar',
'init_xml': [],
"depends" : ["base", "product", "sale", "account_discount_payment"],
'update_xml': [
'data': [
'sale_channel_view.xml',
'partner_view.xml',
'product_view.xml',
'sale_view.xml',
],
'demo_xml': [],
'demo': [],
'test': [],
'installable': True,
'active': False,
......
......@@ -54,4 +54,35 @@ class product_product(models.Model):
return True
product_product()
class product_template(models.Model):
_name = 'product.template'
_inherit = 'product.template'
sale_channel_ids = fields.One2many('sale.channel.product.line', 'product_id', 'Sale Channels')
@api.multi
def button_update_channels(self):
channel_obj = self.env['sale.channel']
product_channel_obj = self.env['sale.channel.product.line']
# Buscamos todos los sale channels actuales
channel_ids = [channel.id for channel in channel_obj.search([])]
# Obtenemos los sale_channels referenciados por este producto
product_channel_ids = self.sale_channel_ids
product_channels = [channel.channel_id for channel in product_channel_ids]
channels_on_product = [p.id for p in product_channels]
# Obtenemos los canales que todavia no estan en el producto
channels_to_add = filter(lambda x: x not in channels_on_product, channel_ids)
# Creamos las nuevas lineas de canales de venta para los canales que faltan en ese producto
for chan_id in channels_to_add:
prod_channel_vals = {
'channel_id': chan_id,
'product_id': self.id
}
product_channel_obj.create(prod_channel_vals)
return True
......@@ -23,6 +23,28 @@
</page>
</field>
</record>
<record model="ir.ui.view" id="view_product_template_sale_channel_form">
<field name="name">product.template.sale.channel.form</field>
<field name="model">product.template</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<page string="Sales" position="after">
<page string="Sale Channels" attrs="{'invisible':[('sale_ok','=',False)]}">
<field name="sale_channel_ids" nolabel="1" colspan="4">
<tree string="Sale Channels" editable="bottom">
<field name="channel_id" readonly="1"/>
<field name="main_percent" string="Main Percent"/>
<field name="offer_percent" string="Offer Percent"/>
<field name="variation_percent" string="Variation Percent"/>
</tree>
</field>
<button name="button_update_channels" string="Update Channels" type="object"/>
</page>
</page>
</field>
</record>
</data>
</openerp>
......@@ -123,6 +123,7 @@ class sale_channel_product_line(models.Model):
main_pricelist_item_id = fields.Many2one('product.pricelist.item')
variation_pricelist_item_id = fields.Many2one('product.pricelist.item')
offer_pricelist_item_id = fields.Many2one('product.pricelist.item')
product_tmpl_id = fields.Many2one('product.template', 'Product')
product_id = fields.Many2one('product.product', 'Product')
@api.model
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment