mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-26 19:32:01 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,21 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models, _
|
||||
from odoo import models, fields, _
|
||||
from odoo.fields import Domain
|
||||
|
||||
|
||||
class UoM(models.Model):
|
||||
class UomUom(models.Model):
|
||||
_inherit = 'uom.uom'
|
||||
|
||||
@api.onchange('rounding')
|
||||
def _onchange_rounding(self):
|
||||
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
|
||||
if self.rounding < 1.0 / 10.0**precision:
|
||||
return {'warning': {
|
||||
'title': _('Warning!'),
|
||||
'message': _(
|
||||
"This rounding precision is higher than the Decimal Accuracy"
|
||||
" (%s digits).\nThis may cause inconsistencies in computations.\n"
|
||||
"Please set a precision between %s and 1."
|
||||
) % (precision, 1.0 / 10.0**precision),
|
||||
}}
|
||||
def _domain_product_uoms(self):
|
||||
domain = []
|
||||
if self.env.context.get("product_id"):
|
||||
domain.append(Domain('product_id', '=', self.env.context['product_id']))
|
||||
if self.env.context.get("product_ids"):
|
||||
domain.append(Domain('product_id', 'in', self.env.context['product_ids']))
|
||||
return Domain.OR(domain) if domain else Domain.TRUE
|
||||
|
||||
product_uom_ids = fields.One2many('product.uom', 'uom_id', string='Barcodes', domain=_domain_product_uoms)
|
||||
|
||||
def action_open_packaging_barcodes(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': _('Packaging Barcodes'),
|
||||
'res_model': 'product.uom',
|
||||
'view_mode': 'list',
|
||||
'view_id': self.env.ref('product.product_uom_list_view').id,
|
||||
'domain': [('uom_id', '=', self.id)],
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue