优化表面工艺

This commit is contained in:
jinling.yang
2024-08-05 17:28:48 +08:00
parent ed0d57c364
commit 5393ef686a
4 changed files with 118 additions and 82 deletions

View File

@@ -211,6 +211,37 @@ class RePurchaseOrder(models.Model):
if not line.taxes_id:
raise UserError('请对【产品】中的【税】进行选择')
def get_purchase_order(self, production, product_id_to_production_names):
for pp in production.product_id.model_process_parameters_ids:
if pp.gain_way == '外协':
server_product = self.env['product.template'].search(
[('server_product_process_parameters_id', '=', pp.id),
('detailed_type', '=', 'service')])
purchase_order_line = self.env['purchase.order.line'].search(
[('product_id', '=', server_product.id)])
if not purchase_order_line:
is_exist = False
else:
for item in purchase_order_line:
purchase_order = self.env['purchase.order'].search(
[('state', '=', 'draft'), ('origin', 'ilike', production.name),
('id', '=', item.order_id)])
if not purchase_order:
is_exist = False
if is_exist is False:
production_process = product_id_to_production_names.get(
production.product_id.id)
self.env['purchase.order'].sudo().create({
'partner_id': server_product.seller_ids.partner_id.id,
'origin': ','.join(production_process),
'state': 'draft',
'order_line': [(0, 0, {
'product_id': server_product.product_variant_id.id,
'product_qty': len(production_process),
'product_uom': server_product.uom_id.id
})]
})
@api.onchange('order_line')
def _onchange_order_line(self):
for order in self:
@@ -237,7 +268,6 @@ class ResPartnerToSale(models.Model):
_inherit = 'res.partner'
purchase_user_id = fields.Many2one('res.users', '采购员')
translated_display_name = fields.Char('11')
@api.constrains('name')
def _check_name(self):