| 1 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 2 |
from odoo import api, fields, models |
| 3 |
|
| 4 |
|
| 5 |
class ProductPricelist(models.Model): |
| 6 |
_name = 'product.pricelist' |
| 7 |
_inherit = ['product.pricelist', 'pos.load.mixin'] |
| 8 |
|
| 9 |
@api.model |
| 10 |
def _load_pos_data_domain(self, data, config): |
| 11 |
pricelist_ids = [preset['pricelist_id'] for preset in data['pos.preset']] |
| 12 |
return [('id', 'in', config._get_available_pricelists().ids + pricelist_ids)] |
| 13 |
|
| 14 |
@api.model |
| 15 |
def _load_pos_data_fields(self, config): |
| 16 |
return ['id', 'name', 'display_name', 'item_ids'] |
| 17 |
|
| 18 |
|
| 19 |
class ProductPricelistItem(models.Model): |
| 20 |
_name = 'product.pricelist.item' |
| 21 |
_inherit = ['product.pricelist.item', 'pos.load.mixin'] |
| 22 |
|
| 23 |
@api.model |
| 24 |
def _load_pos_data_domain(self, data, config): |
| 25 |
product_tmpl_ids = [p['product_tmpl_id'] for p in data['product.product']] |
| 26 |
product_ids = [p['id'] for p in data['product.product']] |
| 27 |
product_categ = [c['id'] for c in data['product.category']] |
| 28 |
pricelist_ids = [p['id'] for p in data['product.pricelist']] |
| 29 |
now = fields.Datetime.now() |
| 30 |
return [ |
| 31 |
('pricelist_id', 'in', pricelist_ids), |
| 32 |
'|', ('product_tmpl_id', '=', False), ('product_tmpl_id', 'in', product_tmpl_ids), |
| 33 |
'|', ('product_id', '=', False), ('product_id', 'in', product_ids), |
| 34 |
'|', ('date_start', '=', False), ('date_start', '<=', now), |
| 35 |
'|', ('date_end', '=', False), ('date_end', '>=', now), |
| 36 |
'|', ('categ_id', '=', False), ('categ_id', 'in', product_categ), |
| 37 |
] |
| 38 |
|
| 39 |
@api.model |
| 40 |
def _load_pos_data_fields(self, config): |
| 41 |
return ['product_tmpl_id', 'product_id', 'pricelist_id', 'price_surcharge', 'price_discount', 'price_round', |
| 42 |
'price_min_margin', 'price_max_margin', 'company_id', 'currency_id', 'date_start', 'date_end', 'compute_price', |
| 43 |
'fixed_price', 'percent_price', 'base_pricelist_id', 'base', 'categ_id', 'min_quantity'] |