Debian Codegraph @

addons/point_of_sale/models/pos_bill.py

raw
1 from odoo import api, fields, models, _
2 from odoo.exceptions import UserError
3
4
5 class PosBill(models.Model):
6 _name = 'pos.bill'
7 _order = "value"
8 _description = "Coins/Bills"
9 _inherit = ["pos.load.mixin"]
10
11 name = fields.Char("Name")
12 value = fields.Float("Value", required=True, digits=(16, 4))
13 pos_config_ids = fields.Many2many("pos.config", string="Point of Sales")
14
15 @api.model
16 def name_create(self, name):
17 try:
18 value = float(name)
19 except ValueError:
20 raise UserError(_("The name of the Coins/Bills must be a number."))
21 result = super().create({"name": name, "value": value})
22 return result.id, result.display_name
23
24 @api.model
25 def _load_pos_data_domain(self, data, config):
26 return ['|', ('id', 'in', config.default_bill_ids.ids), ('pos_config_ids', '=', False)]
27
28 @api.model
29 def _load_pos_data_fields(self, config):
30 return ['id', 'name', 'value']