summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-11-29 09:53:07 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-11-29 09:53:07 +0700
commit0080b6b1da5f181cee32fae7bb5166ce65165374 (patch)
tree01b2a5ccbcef4edc45c17f5fcdab7093767995a6
parent58bec36c52b223c12fd15511a56ab417ebbd7257 (diff)
cr note product promotion
-rwxr-xr-xindoteknik_custom/models/product_template.py2
-rw-r--r--indoteknik_custom/models/promotion/sale_order.py11
-rwxr-xr-xindoteknik_custom/views/product_template.xml6
3 files changed, 14 insertions, 5 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 25473ab8..2e80beec 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -61,6 +61,7 @@ class ProductTemplate(models.Model):
sni = fields.Boolean(string='SNI')
tkdn = fields.Boolean(string='TKDN')
short_spesification = fields.Char(string='Short Spesification')
+ merchandise_ok = fields.Boolean(string='Product Promotion')
@api.constrains('name', 'internal_reference', 'x_manufacture')
def required_public_categ_ids(self):
@@ -377,6 +378,7 @@ class ProductProduct(models.Model):
max_qty_reorder = fields.Float(string='Max Qty Reorder', compute='_get_max_qty_reordering_rule')
qty_rpo = fields.Float(string='Qty RPO', compute='_get_qty_rpo')
plafon_qty = fields.Float(string='Max Plafon', compute='_get_plafon_qty_product')
+ merchandise_ok = fields.Boolean(string='Product Promotion')
def _get_clean_website_description(self):
for rec in self:
diff --git a/indoteknik_custom/models/promotion/sale_order.py b/indoteknik_custom/models/promotion/sale_order.py
index be820c6f..1c31d060 100644
--- a/indoteknik_custom/models/promotion/sale_order.py
+++ b/indoteknik_custom/models/promotion/sale_order.py
@@ -10,11 +10,12 @@ class SaleOrder(models.Model):
for promotion in promotions:
program_line = self.env['promotion.program.line'].browse(promotion['program_line_id'])
for free_product in program_line.free_product_ids:
- self.env['sale.order.line'].create({
- 'order_id': self.id,
- 'name': "Free Product " + free_product.product_id.display_name,
- 'display_type': 'line_note'
- })
+ if free_product.product_id.merchandise_ok:
+ self.env['sale.order.line'].create({
+ 'order_id': self.id,
+ 'name': f"Free Product {free_product.product_id.display_name} Quantity ({free_product.qty})",
+ 'display_type': 'line_note'
+ })
def apply_promotion_program(self):
userdata = {
diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml
index 5a509ebd..b6599137 100755
--- a/indoteknik_custom/views/product_template.xml
+++ b/indoteknik_custom/views/product_template.xml
@@ -24,6 +24,12 @@
<field name="public_categ_ids" position="attributes">
<attribute name="required">0</attribute>
</field>
+ <div name="options" position="inside">
+ <div>
+ <field name="merchandise_ok"/>
+ <label for="merchandise_ok"/>
+ </div>
+ </div>
<field name="public_categ_ids" position="attributes">
<attribute name="options">{'no_create': True}</attribute>
</field>