From dfba055019c7b91725dc8f88f8da9b9bf6b8064b Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Fri, 19 Jul 2024 16:45:46 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0bfm=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=97=B6=E4=BA=A7=E5=93=81=E5=88=9B=E5=BB=BA=E5=A1=AB=E5=85=85?= =?UTF-8?q?=E7=A8=8E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_sale/models/sale_order.py | 70 ++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index f47f8c8d..f2d4073e 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -56,7 +56,7 @@ class ReSaleOrder(models.Model): deadline_of_delivery, payments_way, pay_way): now_time = datetime.datetime.now() partner = self.get_customer() - order_id = self.env['sale.order'].sudo().create({ + data ={ 'company_id': company_id.id, 'date_order': now_time, 'name': self.env['ir.sequence'].next_by_code('sale.order', sequence_date=now_time), @@ -67,10 +67,18 @@ class ReSaleOrder(models.Model): 'person_of_delivery': delivery_name, 'telephone_of_delivery': delivery_telephone, 'address_of_delivery': delivery_address, - 'deadline_of_delivery': deadline_of_delivery, 'payments_way': payments_way, 'pay_way': pay_way, - }) + } + if deadline_of_delivery: + # deadline_of_delivery字段存在为false字符串情况 + if not isinstance(deadline_of_delivery, str): + data.update({'deadline_of_delivery': deadline_of_delivery}) + else: + if deadline_of_delivery!="False": + data.update({'deadline_of_delivery': deadline_of_delivery}) + + order_id = self.env['sale.order'].sudo().create(data) return order_id def write(self, vals): @@ -113,6 +121,7 @@ class ReSaleOrder(models.Model): 'price_unit': product.list_price, 'product_uom_qty': item['number'], 'model_glb_file': base64.b64decode(item['model_file']), + 'remark': item.get('remark') } return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals) @@ -151,6 +160,7 @@ class ResaleOrderLine(models.Model): # # without modifying the related product_id when updated. # domain=[('sale_ok', '=', True), ('categ_type', '=', '成品')]) check_status = fields.Selection(related='order_id.check_status') + remark = fields.Char('备注') @api.depends('product_template_id') def _compute_model_glb_file(self): @@ -256,33 +266,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): From a0d3b40548b1f2bce5054290e73dffe556335e54 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Fri, 19 Jul 2024 16:46:31 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E5=8E=82?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=92=8C=E4=BA=A7=E5=93=81=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_sale/models/quick_easy_order.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index e3bf3002..5272d7a5 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -371,6 +371,7 @@ class QuickEasyOrder(models.Model): product_bom_purchase.bom_create_line_has(purchase_embryo) order_id.with_user(self.env.ref("base.user_admin")).sale_order_create_line(product, item) except Exception as e: + logging.error('工厂创建销售订单和产品失败,请联系管理员'.format(e)) # self.cr.rollback() return UserError('工厂创建销售订单和产品失败,请联系管理员') From 03fe730c50fb1552a86ff00463bb833c400392be Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Fri, 19 Jul 2024 16:46:53 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BA=A7=E5=93=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=A8=8E=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 4d05de81..400cf0d6 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -640,6 +640,10 @@ class ResProductMo(models.Model): 'part_number': item.get('part_number') or '', 'active': True, } + tax_id = self.env['account.tax'].sudo().search( + [('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')]) + if tax_id: + vals.update({'taxes_id':[(6,0,[int(tax_id)])]}) copy_product_id.sudo().write(vals) product_id.product_tmpl_id.active = False return copy_product_id @@ -947,6 +951,7 @@ class SfMaintenanceEquipmentAndProductTemplate(models.Model): raise ValidationError("机床基坐标获取失败") +sf_man class SfMaintenanceEquipmentTool(models.Model): _name = 'maintenance.equipment.tool' _description = '机床刀位' From ef1c7b6b25105717bf5a68b649e70cee39b082cc Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Fri, 19 Jul 2024 17:23:01 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A4=9A=E4=BD=99=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 400cf0d6..7f67adc5 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -951,7 +951,7 @@ class SfMaintenanceEquipmentAndProductTemplate(models.Model): raise ValidationError("机床基坐标获取失败") -sf_man + class SfMaintenanceEquipmentTool(models.Model): _name = 'maintenance.equipment.tool' _description = '机床刀位' From 510e8d49fb788180c87b56d59ccbd1dc468a744e Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Thu, 1 Aug 2024 10:46:14 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7?= =?UTF-8?q?=E6=8B=86=E8=A7=A3=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 83fa3b36..65475333 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -1103,7 +1103,7 @@ class StockMove(models.Model): move_line_ids = picking_id.move_line_ids for move_line_id in move_line_ids: for res in data: - if move_line_id.lot_id.product_id == res['lot_id'].product_id: + if move_line_id.product_id == res['lot_id'].product_id: move_line_id.write({ 'destination_location_id': res.get('destination').id, 'lot_id': res.get('lot_id').id