Advertisement
Guest User

Untitled

a guest
May 28th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. class CrossUom(DeactivableMixin, ModelSQL, ModelView):
  2.     "Cross Unit of Measure"
  3.     __name__ = 'product.cross_uom'
  4.     name = fields.Function(fields.Char("Name"), 'get_name')
  5.     symbol = fields.Function(fields.Char("Symbol"), 'get_symbol')
  6.     category = fields.Many2One(
  7.         'product.uom.category', "Category", required=True, ondelete='RESTRICT',
  8.         help="The category that contains the unit of measure.\n"
  9.         "Conversions between different units of measure can be done if they "
  10.         "are in the same category.")
  11.     first_uom = fields.Many2One('product.uom', 'First UOM',
  12.         required=True)
  13.     second_uom = fields.Many2One('product.uom', 'Second UOM',
  14.         required=True)
  15.     rate = fields.Float(
  16.         "Rate", digits=uom_conversion_digits, required=True,
  17.         help="The coefficient for the formula:\n"
  18.         "1 (base unit) = coef (this unit)")
  19.     factor = fields.Float(
  20.         "Factor", digits=uom_conversion_digits, required=True,
  21.         help="The coefficient for the formula:\n"
  22.         "coefficient (base unit) = 1 (this unit)")
  23.     rounding = fields.Float(
  24.         "Rounding Precision", digits=(12, Eval('digits', 12)), required=True,
  25.         domain=[
  26.             ('rounding', '>', 0),
  27.             ],
  28.         depends=['digits'],
  29.         help="The accuracy to which values are rounded.")
  30.     digits = fields.Integer(
  31.         "Display Digits", required=True,
  32.         help="The number of digits to display after the decimal separator.")
  33.  
  34.     def get_name(self, name):
  35.         uom_name = ""
  36.         if self.first_uom and self.second_uom:
  37.             uom_name = "%s by %s" % (self.first_uom.name, self.second_uom.name)
  38.         return uom_name
  39.  
  40.     def get_symbol(self, name):
  41.         uom_symbol = ""
  42.         if self.first_uom and self.second_uom:
  43.             uom_symbol = "%s/%s" % (self.first_uom.symbol,
  44.                 self.second_uom.symbol)
  45.         return uom_symbol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement