oca-ocb-sale/odoo-bringout-oca-ocb-point_of_sale/point_of_sale/models/pos_bill.py
Ernad Husremovic 73afc09215 19.0 vanilla
2026-03-09 09:32:12 +01:00

30 lines
968 B
Python

from odoo import api, fields, models, _
from odoo.exceptions import UserError
class PosBill(models.Model):
_name = 'pos.bill'
_order = "value"
_description = "Coins/Bills"
_inherit = ["pos.load.mixin"]
name = fields.Char("Name")
value = fields.Float("Value", required=True, digits=(16, 4))
pos_config_ids = fields.Many2many("pos.config", string="Point of Sales")
@api.model
def name_create(self, name):
try:
value = float(name)
except ValueError:
raise UserError(_("The name of the Coins/Bills must be a number."))
result = super().create({"name": name, "value": value})
return result.id, result.display_name
@api.model
def _load_pos_data_domain(self, data, config):
return ['|', ('id', 'in', config.default_bill_ids.ids), ('pos_config_ids', '=', False)]
@api.model
def _load_pos_data_fields(self, config):
return ['id', 'name', 'value']