1、完成 SF材料材料型号缺陷优化 bug
This commit is contained in:
@@ -61,12 +61,10 @@ class MrsMaterialModel(models.Model):
|
||||
supplier_ids = fields.One2many('sf.supplier.sort', 'materials_model_id', string='供应商')
|
||||
active = fields.Boolean('有效', default=True)
|
||||
|
||||
@api.onchange('gain_way')
|
||||
def _check_gain_way(self):
|
||||
if not self.gain_way:
|
||||
raise UserError("请选择获取方式")
|
||||
if self.gain_way in ['外协', '采购']:
|
||||
if not self.supplier_ids:
|
||||
@api.constrains("gain_way")
|
||||
def _check_supplier_ids(self):
|
||||
for item in self:
|
||||
if item.gain_way in ('外协', '采购') and not item.supplier_ids:
|
||||
raise UserError("请添加供应商")
|
||||
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="materials_no" readonly="1" force_save="1"/>
|
||||
<field name="gain_way" required="1"/>
|
||||
<field name="gain_way" required="0"/>
|
||||
<field name="tensile_strength" required="1"/>
|
||||
<field name="hardness" required="1"/>
|
||||
<field name="density" readonly="1"/>
|
||||
@@ -270,9 +270,9 @@
|
||||
<notebook>
|
||||
<page string="供应商">
|
||||
<field name='supplier_ids' class="supplier_ids_set_css">
|
||||
<tree editable='bottom'>
|
||||
<tree editable='bottom' delete="1">
|
||||
<field name="sequence" widget="handle" string="序号"/>
|
||||
<field name="partner_id" string="名称"/>
|
||||
<field name="partner_id" string="名称" options="{'no_create': True}"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
@@ -256,33 +256,33 @@ class ResPartnerToSale(models.Model):
|
||||
# if obj:
|
||||
# raise UserError('该邮箱已存在,请重新输入')
|
||||
|
||||
@api.model
|
||||
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||
if self._context.get('is_customer'):
|
||||
if self.env.user.has_group('sf_base.group_sale_director'):
|
||||
domain = [('customer_rank', '>', 0)]
|
||||
elif self.env.user.has_group('sf_base.group_sale_salemanager'):
|
||||
customer = self.env['res.partner'].search(
|
||||
[('customer_rank', '>', 0), ('user_id', '=', self.env.user.id)])
|
||||
if customer:
|
||||
ids = [t.id for t in customer]
|
||||
domain = [('id', 'in', ids)]
|
||||
else:
|
||||
domain = [('id', '=', False)]
|
||||
return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||
elif self._context.get('is_supplier') or self.env.user.has_group('sf_base.group_purchase_director'):
|
||||
if self.env.user.has_group('sf_base.group_purchase_director'):
|
||||
domain = [('supplier_rank', '>', 0)]
|
||||
elif self.env.user.has_group('sf_base.group_purchase'):
|
||||
supplier = self.env['res.partner'].search(
|
||||
[('supplier_rank', '>', 0), ('purchase_user_id', '=', self.env.user.id)])
|
||||
if supplier:
|
||||
ids = [t.id for t in supplier]
|
||||
domain = [('id', 'in', ids)]
|
||||
else:
|
||||
domain = [('id', '=', False)]
|
||||
return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||
return super()._name_search(name, args, operator, limit, name_get_uid)
|
||||
# @api.model
|
||||
# def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
|
||||
# if self._context.get('is_customer'):
|
||||
# if self.env.user.has_group('sf_base.group_sale_director'):
|
||||
# domain = [('customer_rank', '>', 0)]
|
||||
# elif self.env.user.has_group('sf_base.group_sale_salemanager'):
|
||||
# customer = self.env['res.partner'].search(
|
||||
# [('customer_rank', '>', 0), ('user_id', '=', self.env.user.id)])
|
||||
# if customer:
|
||||
# ids = [t.id for t in customer]
|
||||
# domain = [('id', 'in', ids)]
|
||||
# else:
|
||||
# domain = [('id', '=', False)]
|
||||
# return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||
# elif self._context.get('is_supplier') or self.env.user.has_group('sf_base.group_purchase_director'):
|
||||
# if self.env.user.has_group('sf_base.group_purchase_director'):
|
||||
# domain = [('supplier_rank', '>', 0)]
|
||||
# elif self.env.user.has_group('sf_base.group_purchase'):
|
||||
# supplier = self.env['res.partner'].search(
|
||||
# [('supplier_rank', '>', 0), ('purchase_user_id', '=', self.env.user.id)])
|
||||
# if supplier:
|
||||
# ids = [t.id for t in supplier]
|
||||
# domain = [('id', 'in', ids)]
|
||||
# else:
|
||||
# domain = [('id', '=', False)]
|
||||
# return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
|
||||
# return super()._name_search(name, args, operator, limit, name_get_uid)
|
||||
|
||||
@api.onchange('user_id')
|
||||
def _get_salesman(self):
|
||||
|
||||
Reference in New Issue
Block a user