From 9ed51cb823a031e2d9a700499d6f225079f9d491 Mon Sep 17 00:00:00 2001 From: Juliana Date: Tue, 11 May 2021 12:07:53 +0200 Subject: [PATCH] Add depublication auto + Get info product ref for pack --- models/product_template.py | 25 +++++++++++++++++++++++-- security/ir.model.access.csv | 3 ++- views/product_template_views.xml | 5 +++++ views/templates.xml | 2 +- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/models/product_template.py b/models/product_template.py index 9bb467d..9a7d31c 100644 --- a/models/product_template.py +++ b/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 - \ No newline at end of file + + @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)] + }) \ No newline at end of file diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index 4c90689..7e4a45f 100644 --- a/security/ir.model.access.csv +++ b/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 \ No newline at end of file +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 \ No newline at end of file diff --git a/views/product_template_views.xml b/views/product_template_views.xml index afe7590..a43bb4f 100644 --- a/views/product_template_views.xml +++ b/views/product_template_views.xml @@ -6,6 +6,11 @@ product.template +
+
diff --git a/views/templates.xml b/views/templates.xml index 3c028a2..3c02feb 100644 --- a/views/templates.xml +++ b/views/templates.xml @@ -4,7 +4,7 @@