增加排程动作对销售订单状态的修改

This commit is contained in:
mgw
2024-01-12 16:40:29 +08:00
parent b5147678b1
commit f19af2a33f
3 changed files with 20 additions and 11 deletions

View File

@@ -8,8 +8,6 @@ from odoo.exceptions import UserError
from odoo.addons.sf_base.commons.common import Common
from odoo.tools import float_compare, float_round, float_is_zero, format_datetime
from odoo.tools import float_compare, float_is_zero
class MrpProduction(models.Model):
_inherit = 'mrp.production'
@@ -162,7 +160,6 @@ class MrpProduction(models.Model):
logging.info('fetchCNC error:%s' % e)
raise UserError("cnc程序获取编程单失败,请联系管理员")
# 维修模块按钮
def button_maintenance_req(self):
self.ensure_one()
@@ -489,7 +486,7 @@ class MrpProduction(models.Model):
self._reset_work_order_sequence()
return True
#修改标记已完成方法
# 修改标记已完成方法
def button_mark_done1(self):
self._button_mark_done_sanity_checks()
@@ -506,7 +503,6 @@ class MrpProduction(models.Model):
productions_not_to_backorder = self
productions_to_backorder = self.env['mrp.production']
backorders = productions_to_backorder and productions_to_backorder._split_productions()
backorders = backorders - productions_to_backorder
@@ -514,13 +510,16 @@ class MrpProduction(models.Model):
productions_to_backorder._post_inventory(cancel_backorder=True)
# if completed products make other confirmed/partially_available moves available, assign them
done_move_finished_ids = (productions_to_backorder.move_finished_ids | productions_not_to_backorder.move_finished_ids).filtered(lambda m: m.state == 'done')
done_move_finished_ids = (
productions_to_backorder.move_finished_ids | productions_not_to_backorder.move_finished_ids).filtered(
lambda m: m.state == 'done')
done_move_finished_ids._trigger_assign()
# Moves without quantity done are not posted => set them as done instead of canceling. In
# case the user edits the MO later on and sets some consumed quantity on those, we do not
# want the move lines to be canceled.
(productions_not_to_backorder.move_raw_ids | productions_not_to_backorder.move_finished_ids).filtered(lambda x: x.state not in ('done', 'cancel')).write({
(productions_not_to_backorder.move_raw_ids | productions_not_to_backorder.move_finished_ids).filtered(
lambda x: x.state not in ('done', 'cancel')).write({
'state': 'done',
'product_uom_qty': 0.0,
})
@@ -546,8 +545,10 @@ class MrpProduction(models.Model):
'res_id': self.id,
'target': 'main',
}
if self.user_has_groups('mrp.group_mrp_reception_report') and self.picking_type_id.auto_show_reception_report:
lines = self.move_finished_ids.filtered(lambda m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids)
if self.user_has_groups(
'mrp.group_mrp_reception_report') and self.picking_type_id.auto_show_reception_report:
lines = self.move_finished_ids.filtered(lambda
m: m.product_id.type == 'product' and m.state != 'cancel' and m.quantity_done and not m.move_dest_ids)
if lines:
if any(mo.show_allocation for mo in self):
action = self.action_view_reception_report()
@@ -574,4 +575,4 @@ class MrpProduction(models.Model):
'domain': [('id', 'in', backorders.ids)],
'view_mode': 'tree,form',
})
return action
return action