Merge branch 'feature/去掉客户部分字段必填校验和返工报废代码' into develop

This commit is contained in:
jinling.yang
2024-06-17 11:00:02 +08:00
6 changed files with 44 additions and 100 deletions

View File

@@ -215,7 +215,8 @@ class Manufacturing_Connect(http.Controller):
if workorder.state != 'progress': if workorder.state != 'progress':
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'} res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单未开始'}
return json.JSONEncoder().encode(res) return json.JSONEncoder().encode(res)
workorder.write({'date_finished': datetime.now()}) # workorder.write({'date_finished': datetime.now()})
workorder.button_finish()
# workorder.process_state = '待解除装夹' # workorder.process_state = '待解除装夹'
# workorder.sudo().production_id.process_state = '待解除装夹' # workorder.sudo().production_id.process_state = '待解除装夹'

View File

@@ -293,7 +293,7 @@ class MrpProduction(models.Model):
# 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制; # 则根据设备找到工作中心;否则采用前面描述的工作中心分配机制;
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心; # 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
def _create_workorder3(self, is_fetchcnc=False, scrap_production=False): def _create_workorder3(self):
# 根据product_id对self进行分组 # 根据product_id对self进行分组
grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)} grouped_product_ids = {k: list(g) for k, g in groupby(self, key=lambda x: x.product_id.id)}
# 初始化一个字典来存储每个product_id对应的生产订单名称列表 # 初始化一个字典来存储每个product_id对应的生产订单名称列表
@@ -336,12 +336,9 @@ class MrpProduction(models.Model):
production_programming = self.search( production_programming = self.search(
[('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)], [('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)],
limit=1, order='id asc') limit=1, order='id asc')
if not production_programming.programming_no or (is_fetchcnc is True and scrap_production): if not production_programming.programming_no:
# 制造订单报废/返工也需重新编程 production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]),
if (is_fetchcnc is True and scrap_production is False) or ( scrap_production)
is_fetchcnc is False and scrap_production is False):
production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id]),
scrap_production)
else: else:
production.write({'programming_no': production_programming.programming_no, production.write({'programming_no': production_programming.programming_no,
'programming_state': '编程中'}) 'programming_state': '编程中'})
@@ -409,12 +406,6 @@ class MrpProduction(models.Model):
workorders_values.append( workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route)) self.env['mrp.workorder'].json_workorder_str('', production, route))
production.workorder_ids = workorders_values production.workorder_ids = workorders_values
if production_programming.programming_state == '已编程':
logging.info("production_programming: %s" % production_programming.name)
production.workorder_ids.filtered(lambda t: t.routing_type == 'CNC加工').write({
'cnc_ids': production_programming.workorder_ids.filtered(
lambda
t1: t1.routing_type == 'CNC加工').cnc_ids})
for workorder in production.workorder_ids: for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected() workorder.duration_expected = workorder._get_duration_expected()
@@ -557,8 +548,8 @@ class MrpProduction(models.Model):
# work.button_finish() # work.button_finish()
# 创建工单并进行排序 # 创建工单并进行排序
def _create_workorder(self, is_fetchcnc=False, scrap_production=False): def _create_workorder(self):
self._create_workorder3(is_fetchcnc=is_fetchcnc, scrap_production=scrap_production) self._create_workorder3()
self._reset_work_order_sequence() self._reset_work_order_sequence()
return True return True

View File

@@ -996,15 +996,15 @@ class ResMrpWorkOrder(models.Model):
record.write({ record.write({
'date_planned_finished': tem_date_planned_finished # 保持原值 'date_planned_finished': tem_date_planned_finished # 保持原值
}) })
if record.routing_type == 'CNC加工': # if record.routing_type == 'CNC加工':
record.write({ # record.write({
'date_finished': tem_date_finished # 保持原值 # 'date_finished': tem_date_finished # 保持原值
}) # })
if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']: # if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
record.production_id.action_cancel() # record.production_id.action_cancel()
record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code}) # record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code})
if record.is_remanufacture is True: # if record.is_remanufacture is True:
record.recreateManufacturingOrWorkerOrder() # record.recreateManufacturingOrWorkerOrder()
is_production_id = True is_production_id = True
for workorder in record.production_id.workorder_ids: for workorder in record.production_id.workorder_ids:
if workorder.state != 'done': if workorder.state != 'done':

View File

@@ -233,12 +233,12 @@ class ResPartnerToSale(models.Model):
if obj: if obj:
raise UserError('该税ID已存在,请重新输入') raise UserError('该税ID已存在,请重新输入')
@api.constrains('email') # @api.constrains('email')
def _check_email(self): # def _check_email(self):
if self.customer_rank > 0: # if self.customer_rank > 0:
obj = self.sudo().search([('email', '=', self.email), ('id', '!=', self.id), ('active', '=', True)]) # obj = self.sudo().search([('email', '=', self.email), ('id', '!=', self.id), ('active', '=', True)])
if obj: # if obj:
raise UserError('该邮箱已存在,请重新输入') # raise UserError('该邮箱已存在,请重新输入')
@api.model @api.model
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):

View File

@@ -24,18 +24,18 @@
<attribute name="required">1</attribute> <attribute name="required">1</attribute>
<attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute> <attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute>
</field> </field>
<field name="email" position="replace"> <!-- <field name="email" position="replace">-->
<field name="email" <!-- <field name="email"-->
attrs="{'readonly': [('id','!=', False)]}"/> <!-- attrs="{'readonly': [('id','!=', False)]}"/>-->
</field> <!-- </field>-->
<field name="mobile" position="attributes"> <!-- <field name="mobile" position="attributes">-->
<attribute name="attrs">{'required': [('phone', '=', False)],'readonly': [('id','!=', False)]} <!-- <attribute name="attrs">{'required': [('phone', '=', False)],'readonly': [('id','!=', False)]}-->
</attribute> <!-- </attribute>-->
</field> <!-- </field>-->
<field name="phone" position="attributes"> <!-- <field name="phone" position="attributes">-->
<attribute name="attrs">{'required': [('mobile', '=', False)],'readonly': [('id','!=', False)]} <!-- <attribute name="attrs">{'required': [('mobile', '=', False)],'readonly': [('id','!=', False)]}-->
</attribute> <!-- </attribute>-->
</field> <!-- </field>-->
<field name="street" position="attributes"> <field name="street" position="attributes">
<attribute name="attrs">{'readonly': [('id','!=', False)]} <attribute name="attrs">{'readonly': [('id','!=', False)]}
</attribute> </attribute>
@@ -56,10 +56,10 @@
<field name="user_id" widget="many2one_avatar_user" context="{'is_sale': True }" <field name="user_id" widget="many2one_avatar_user" context="{'is_sale': True }"
attrs="{'required' : [('customer_rank','>', 0)]}"/> attrs="{'required' : [('customer_rank','>', 0)]}"/>
</xpath> </xpath>
<field name="category_id" position="attributes"> <!-- <field name="category_id" position="attributes">-->
<attribute name="required">1</attribute> <!-- <attribute name="required">1</attribute>-->
<attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute> <!-- <attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute>-->
</field> <!-- </field>-->
<field name="company_registry" position="attributes"> <field name="company_registry" position="attributes">
<attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute> <attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute>
</field> </field>
@@ -101,7 +101,7 @@
<field name="property_supplier_payment_term_id" position="before"> <field name="property_supplier_payment_term_id" position="before">
<field name="purchase_user_id" context="{'supplier_rank': supplier_rank }" <field name="purchase_user_id" context="{'supplier_rank': supplier_rank }"
widget="many2one_avatar_user" widget="many2one_avatar_user"
attrs="{'required' : [('supplier_rank','>', 0)],'readonly': [('customer_rank','>', 0)]}"/> attrs="{'required' : [('supplier_rank','>', 0)]}"/>
</field> </field>
<xpath expr="//field[@name='property_account_position_id']" position="attributes"> <xpath expr="//field[@name='property_account_position_id']" position="attributes">
<attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute> <attribute name="attrs">{'readonly': [('id','!=', False)]}</attribute>
@@ -195,10 +195,10 @@
<attribute name="attrs">{'invisible': [('customer_rank','=', 0)]} <attribute name="attrs">{'invisible': [('customer_rank','=', 0)]}
</attribute> </attribute>
</field> </field>
<field name="user_id" position="before"> <!-- <field name="user_id" position="before">-->
<field name="purchase_user_id" widget="many2one_avatar_user" <!-- <field name="purchase_user_id" widget="many2one_avatar_user"-->
attrs="{'invisible' : [('supplier_rank','=', 0)]}"/> <!-- attrs="{'invisible' : [('supplier_rank','=', 0)]}"/>-->
</field> <!-- </field>-->
</field> </field>
</record> </record>
</data> </data>

View File

@@ -1,54 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<odoo> <odoo>
<data> <data>
<record id="sale_order_view_search_inherit_sf" model="ir.ui.view">
<field name="name">sale.order.search.inherit.sf</field>
<field name="model">sale.order</field>
<field name="mode">primary</field>
<field name="inherit_id" ref="sale.view_sales_order_filter"/>
<field name="arch" type="xml">
<filter name="my_sale_orders_filter" position="replace">
<field name="campaign_id"/>
<separator/>
<filter string="报价" name="draft" domain="[('state','in',('draft', 'sent'))]"/>
<filter string="销售订单" name="sales" domain="[('state','in',('sale','done'))]"/>
<separator/>
<filter string="创建日期" name="filter_create_date" date="create_date"/>
</filter>
</field>
</record>
<record id="action_quotations_with_onboarding_inherit_sf" model="ir.actions.act_window">
<field name="name">报价</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_id" ref="sale.view_quotation_tree_with_onboarding"/>
<field name="view_mode">tree,kanban,form,calendar,pivot,graph,activity</field>
<field name="search_view_id" ref="sale_order_view_search_inherit_sf"/>
<field name="context">{'search_default_my_quotation': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new quotation, the first step of a new sale!
</p>
<p>
Once the quotation is confirmed by the customer, it becomes a sales order.
<br/>
You will be able to create an invoice and collect the payment.
</p>
</field>
</record>
<!-- <menuitem id="menu_sale_quotations">-->
<!-- <field name="active" eval="False"/>-->
<!-- </menuitem>-->
<menuitem id="menu_sale_quotations_inherit_sf"
action="action_quotations_with_onboarding_inherit_sf"
groups="sales_team.group_sale_salesman,sf_base.group_sale_salemanager,sf_base.group_sale_director"
parent="sale.sale_order_menu"
sequence="11"/>
<record model="ir.ui.view" id="view_sale_order_form_inherit_sf"> <record model="ir.ui.view" id="view_sale_order_form_inherit_sf">
<field name="name">sale.order.form.inherit.sf</field> <field name="name">sale.order.form.inherit.sf</field>
<field name="model">sale.order</field> <field name="model">sale.order</field>