Files
odoo_source/addons/pos_epson_printer/models/res_config_settings.py
T
Joseph Caburnay 48aff86c42 [FIX] point_of_sale,*pos*: remove 'pos' field attribute
With this change, we are now assuming each field that starts with
'pos_' to be a 'pos.config' field that has value that will be saved
to the 'pos_config_id' record. We made that modification because by keeping
some related fields not written at the same time can trigger contraints at the
wrong moments that would lead to validation errors when not supposed to be.

Part-of: odoo/odoo#97032
2022-07-29 01:51:13 +02:00

27 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, api
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
pos_epson_printer_ip = fields.Char(compute='_compute_pos_epson_printer_ip', store=True, readonly=False)
@api.depends('pos_epson_printer_ip', 'pos_other_devices')
def _compute_pos_iface_cashdrawer(self):
"""We are just adding depends on this compute."""
super()._compute_pos_iface_cashdrawer()
def _is_cashdrawer_displayed(self, res_config):
return super()._is_cashdrawer_displayed(res_config) or (res_config.pos_other_devices and bool(res_config.pos_epson_printer_ip))
@api.depends('pos_other_devices', 'pos_config_id')
def _compute_pos_epson_printer_ip(self):
for res_config in self:
if not res_config.pos_other_devices:
res_config.pos_epson_printer_ip = ''
else:
res_config.pos_epson_printer_ip = res_config.pos_config_id.epson_printer_ip