diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-23 11:50:20 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-23 11:50:20 +0700 |
| commit | dae4a3bf266ba4c19b1ba1d11c52ed9e19259b7c (patch) | |
| tree | 8858e0660aa004b582aedf6f437c0f455f8ad1ef /indoteknik_custom/models/promotion/promotion_product.py | |
| parent | adbc9b985f1c5fb2b2f41f79c686b3a573003e62 (diff) | |
Update promotion program scheme
Diffstat (limited to 'indoteknik_custom/models/promotion/promotion_product.py')
| -rw-r--r-- | indoteknik_custom/models/promotion/promotion_product.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/indoteknik_custom/models/promotion/promotion_product.py b/indoteknik_custom/models/promotion/promotion_product.py new file mode 100644 index 00000000..2fad0f0d --- /dev/null +++ b/indoteknik_custom/models/promotion/promotion_product.py @@ -0,0 +1,29 @@ +from odoo import fields, models + + +class PromotionProduct(models.Model): + _name = "promotion.product" + _rec_name = "product_id" + + product_id = fields.Many2one(comodel_name="product.product", string="Product variant") + qty = fields.Integer(string="Quantity") + program_line_id = fields.Many2one(comodel_name="promotion.program.line", string="Program line") + + def formats(self, purchase_qty=1): + ir_attachment = self.env['ir.attachment'] + + result = [] + for rec in self: + weight = rec.product_id.weight or 0 + result.append({ + 'id': rec.product_id.id, + 'image': ir_attachment.api_image('product.template', 'image_256', rec.product_id.product_tmpl_id.id), + 'display_name': rec.product_id.display_name, + 'name': rec.product_id.name, + 'code': rec.product_id.code, + 'price': rec.product_id.calculate_website_price(), + 'qty': rec.qty * purchase_qty, + 'weight': weight, + 'package_weight': weight * rec.qty + }) + return result
\ No newline at end of file |
