Browse Source

Add depublication auto + Get info product ref for pack

12.0
Juliana 4 years ago
parent
commit
9ed51cb823
  1. 25
      models/product_template.py
  2. 3
      security/ir.model.access.csv
  3. 5
      views/product_template_views.xml
  4. 2
      views/templates.xml

25
models/product_template.py

@ -27,7 +27,6 @@ class ProductTemplate(models.Model):
for pack_line in template.pack_line_ids:
pack_price_ref += pack_line.product_id.list_price
template.list_price_ref_pack = pack_price_ref
# template.list_price_ref_pack = template.pack_line_ids[0].product_id.list_price
def _compute_price_ref_pack_compute(self):
for template in self:
@ -37,4 +36,26 @@ class ProductTemplate(models.Model):
for pack_line in template.pack_line_ids:
pack_price += pack_line.product_id.list_price * pack_line.quantity
template.price_ref_pack_compute = pack_price
@api.multi
def website_publish_button(self):
self.ensure_one()
res = super(ProductTemplate, self).website_publish_button()
# Dépublie les packs enfants si il en existe
if self.used_in_pack_line_ids:
for pack in self.used_in_pack_line_ids:
pack.parent_product_id.write({'website_published': not self.website_published})
return res
@api.multi
def get_info_parent_pack(self):
for pack in self:
if pack.pack_line_ids:
if pack.pack_ok and (
pack.pack_type == 'detailed' and pack.pack_component_price == 'totalized'):
product_parent_id = pack.pack_line_ids[0].product_id
pack.description_sale = product_parent_id.description_sale
if product_parent_id.product_image_ids:
pack.write({
'product_image_ids': [(6, 0, product_parent_id.product_image_ids.ids)]
})

3
security/ir.model.access.csv

@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_pack_line_public,product.pack.line,product_pack.model_product_pack_line,,1,0,0,0
access_product_pack_line_public,product.pack.line,product_pack.model_product_pack_line,,1,0,0,0
access_product_template_public,product.template,product.model_product_template,,1,0,0,0

5
views/product_template_views.xml

@ -6,6 +6,11 @@
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<header position="inside">
<button string="Récupérer les infos Packs" type="object"
name="get_info_parent_pack"
attrs="{'invisible': [('pack_ok', '!=', True)]}"/>
</header>
<field name="list_price" position="after">
<field name="list_price_ref_pack" string="Prix produit référent au kg" widget='monetary' options="{'currency_field': 'currency_id', 'field_digits': True}" attrs="{'invisible': [('pack_ok', '!=', True)]}"/>
<field name="price_ref_pack_compute" string="Prix de vente TTC" widget='monetary' options="{'currency_field': 'currency_id', 'field_digits': True}" attrs="{'invisible': [('pack_ok', '!=', True)]}"/>

2
views/templates.xml

@ -4,7 +4,7 @@
<template id="product_price" inherit_id="website_sale.product_price">
<xpath expr="//h4" position="after">
<t t-if="product.pack_ok">
<h5><span t-esc="product.list_price_ref_pack" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/><span> / kilo</span></h5>
<!-- <h5><span t-esc="product.list_price_ref_pack" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/><span> / kilo</span></h5> -->
</t>
</xpath>
</template>

Loading…
Cancel
Save