智能工厂创建产品
This commit is contained in:
@@ -4,33 +4,28 @@ from odoo.exceptions import ValidationError
|
||||
|
||||
class ResProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
# sale_order_id = fields.Many2one('sale.order')
|
||||
|
||||
purchase_ok = fields.Boolean(default=False)
|
||||
detailed_type = fields.Selection(default='product')
|
||||
list_price = fields.Float(digits=(16, 3))
|
||||
invoice_policy = fields.Selection(default='delivery')
|
||||
model_long = fields.Float('长[mm]', digits=(16, 3))
|
||||
model_width = fields.Float('宽[mm]', digits=(16, 3))
|
||||
model_height = fields.Float('高[mm]', digits=(16, 3))
|
||||
model_volume = fields.Float('体积[mm³]', digits=(16, 3))
|
||||
model_precision = fields.Float('精度要求', digits=(16, 3))
|
||||
materials_id = fields.Many2one('mrs.production.materials', string='材料')
|
||||
# materials_type_id = fields.Many2one('mrs.materials.model', string='型号')
|
||||
# surface_technics_id = fields.Many2one('mrs.production.process', string='表面工艺')
|
||||
# technological_parameter_id = fields.Char('工艺参数')
|
||||
unit_price = fields.Float('单价')
|
||||
amount = fields.Integer('数量')
|
||||
|
||||
# 业务平台分配工厂时调用该方法创建产品
|
||||
def product_create(self, products):
|
||||
self.env['product.template'].create({
|
||||
'name': products['order_number'],
|
||||
'model_long': products['length'],
|
||||
'model_width': products['width'],
|
||||
'model_height': products['height'],
|
||||
'model_volume': products['volume'],
|
||||
'materials_id': products['materials_id'],
|
||||
'unit_price': products['unit_price'],
|
||||
'amount': products['amount'],
|
||||
'barcode':products['barcode'],
|
||||
})
|
||||
def product_create(self, product_id, item, order_id, order_number, i):
|
||||
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||
copy_product_id.product_tmpl_id.active = True
|
||||
vals = {
|
||||
'name': '%s-%s' % (order_id.name, i),
|
||||
'model_long': item['model_long'],
|
||||
'model_width': item['model_width'],
|
||||
'model_height': item['model_height'],
|
||||
'model_volume': item['model_volume'],
|
||||
'list_price': item['price'],
|
||||
'default_code': '%s-%s' % (order_number, i),
|
||||
'barcode': 'cf0bbe2fdad6339d138cdee732750e3e502140c2',
|
||||
# 'barcode': item['barcode'],
|
||||
'active': True
|
||||
}
|
||||
return copy_product_id.sudo().create(vals)
|
||||
|
||||
Reference in New Issue
Block a user