移除销售订单供货方式确认

This commit is contained in:
guanhuan
2025-06-25 14:22:27 +08:00
parent 9f00fddc09
commit d046fd5298
4 changed files with 72 additions and 0 deletions

View File

@@ -15,6 +15,7 @@
'security/ir.model.access.csv',
'views/demand_plan_info.xml',
'views/demand_plan.xml',
'views/sale_order_views.xml',
'wizard/sf_demand_plan_print_wizard_view.xml',
],
'demo': [

View File

@@ -10,6 +10,16 @@ class ReSaleOrder(models.Model):
string='与此销售订单相关联的制造订单',
groups='mrp.group_mrp_user', store=True)
demand_plan_count = fields.Integer(
"需求计划生成计数",
compute='_compute_demand_plan_count',
)
def _compute_demand_plan_count(self):
for line in self:
demand_plan = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', line.id)])
line.demand_plan_count = len(demand_plan)
def sale_order_create_line(self, product, item):
ret = super(ReSaleOrder, self).sale_order_create_line(product, item)
vals = {
@@ -30,3 +40,29 @@ class ReSaleOrder(models.Model):
}
self.env['sf.demand.plan.print.wizard'].sudo().create(wizard_vals)
return ret
def confirm_to_supply_method(self):
self.state = 'sale'
for line in self.order_line:
if line.product_id.auto_machining:
line.supply_method = 'automation'
def action_view_demand_plan(self):
self.ensure_one()
demand_plan_ids = self.env['sf.production.demand.plan'].sudo().search([('sale_order_id', '=', self.id)]).ids
action = {
'res_model': 'sf.production.demand.plan',
'type': 'ir.actions.act_window',
}
if len(demand_plan_ids) == 1:
action.update({
'view_mode': 'form',
'res_id': demand_plan_ids[0],
})
else:
action.update({
'name': _("需求计划"),
'domain': [('id', 'in', demand_plan_ids)],
'view_mode': 'tree',
})
return action

View File

@@ -192,3 +192,9 @@ class SfDemandPlan(models.Model):
if not line.sale_order_line_id:
line.sale_order_line_id = self.sale_order_line_id
return res
def name_get(self):
result = []
for plan in self:
result.append((plan.id, plan.sale_order_id.name))
return result

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_order_form_inherit_plan" model="ir.ui.view">
<field name="name">view.sale.order.form.inherit.plan</field>
<field name="inherit_id" ref="sf_manufacturing.view_order_form_inherit_supply_method"/>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<xpath expr="//header/button[@name='action_confirm'][last()]" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//page/field[@name='order_line']/tree/field[@name='supply_method']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//div[@name='button_box']" position="inside">
<button class="oe_stat_button" name="action_view_demand_plan" type="object" icon="fa-pencil-square-o"
attrs="{'invisible': [('demand_plan_count', '=', 0)]}">
<div class="o_field_widget o_stat_info">
<span class="o_stat_value">
<field name="demand_plan_count"/>
</span>
<span class="o_stat_text">需求计划</span>
</div>
</button>
</xpath>
</field>
</record>
</odoo>