Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CrossUom(DeactivableMixin, ModelSQL, ModelView):
- "Cross Unit of Measure"
- __name__ = 'product.cross_uom'
- name = fields.Function(fields.Char("Name"), 'get_name')
- symbol = fields.Function(fields.Char("Symbol"), 'get_symbol')
- category = fields.Many2One(
- 'product.uom.category', "Category", required=True, ondelete='RESTRICT',
- help="The category that contains the unit of measure.\n"
- "Conversions between different units of measure can be done if they "
- "are in the same category.")
- first_uom = fields.Many2One('product.uom', 'First UOM',
- required=True)
- second_uom = fields.Many2One('product.uom', 'Second UOM',
- required=True)
- rate = fields.Float(
- "Rate", digits=uom_conversion_digits, required=True,
- help="The coefficient for the formula:\n"
- "1 (base unit) = coef (this unit)")
- factor = fields.Float(
- "Factor", digits=uom_conversion_digits, required=True,
- help="The coefficient for the formula:\n"
- "coefficient (base unit) = 1 (this unit)")
- rounding = fields.Float(
- "Rounding Precision", digits=(12, Eval('digits', 12)), required=True,
- domain=[
- ('rounding', '>', 0),
- ],
- depends=['digits'],
- help="The accuracy to which values are rounded.")
- digits = fields.Integer(
- "Display Digits", required=True,
- help="The number of digits to display after the decimal separator.")
- def get_name(self, name):
- uom_name = ""
- if self.first_uom and self.second_uom:
- uom_name = "%s by %s" % (self.first_uom.name, self.second_uom.name)
- return uom_name
- def get_symbol(self, name):
- uom_symbol = ""
- if self.first_uom and self.second_uom:
- uom_symbol = "%s/%s" % (self.first_uom.symbol,
- self.second_uom.symbol)
- return uom_symbol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement