| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
from odoo import fields, models, api |
| 5 |
|
| 6 |
|
| 7 |
class PosConfig(models.Model): |
| 8 |
_inherit = 'pos.config' |
| 9 |
|
| 10 |
crm_team_id = fields.Many2one( |
| 11 |
'crm.team', string="Sales Team", ondelete="set null", index='btree_not_null', |
| 12 |
help="This Point of sale's sales will be related to this Sales Team.") |
| 13 |
down_payment_product_id = fields.Many2one('product.product', |
| 14 |
string="Down Payment Product", |
| 15 |
help="This product will be used as down payment on a sale order.") |
| 16 |
|
| 17 |
def _get_special_products(self): |
| 18 |
res = super()._get_special_products() |
| 19 |
return res | self.env['pos.config'].search([]).mapped('down_payment_product_id') |
| 20 |
|
| 21 |
@api.model |
| 22 |
def _ensure_downpayment_product(self): |
| 23 |
pos_config = self.env.ref('point_of_sale.pos_config_main', raise_if_not_found=False) |
| 24 |
downpayment_product = self.env.ref('pos_sale.default_downpayment_product', raise_if_not_found=False) |
| 25 |
if pos_config and downpayment_product: |
| 26 |
pos_config.write({'down_payment_product_id': downpayment_product.id}) |
| 27 |
|
| 28 |
@api.model |
| 29 |
def load_onboarding_furniture_scenario(self, with_demo_data=True): |
| 30 |
res = super().load_onboarding_furniture_scenario(with_demo_data) |
| 31 |
self._ensure_downpayment_product() |
| 32 |
return res |