flectra/addons/pos_discount/models/pos_config.py

25 lines
1.1 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2018-01-16 11:34:37 +01:00
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
2018-01-16 11:34:37 +01:00
from flectra import api, fields, models
class PosConfig(models.Model):
_inherit = 'pos.config'
def _get_default_discount_product(self):
return self.env.ref('point_of_sale.product_product_consumable')
iface_discount = fields.Boolean(string='Order Discounts', help='Allow the cashier to give discounts on the whole order.')
discount_pc = fields.Float(string='Discount Percentage', default=10, help='The default discount percentage')
discount_product_id = fields.Many2one('product.product', string='Discount Product', domain="[('available_in_pos', '=', True)]", help='The product used to model the discount.', default=_get_default_discount_product)
@api.onchange('module_pos_discount')
def _onchange_module_pos_discount(self):
if self.module_pos_discount:
self.discount_product_id = self.env['product.product'].search([('available_in_pos', '=', True)], limit=1)
self.discount_pc = 10.0
else:
self.discount_product_id = False
self.discount_pc = 0.0