Accept Merge Request #1662: (feature/part_number -> develop)
Merge Request: 委外加工采购单与制造订单进行关联 Created By: @廖丹龙 Reviewed By: @胡尧 Approved By: @胡尧 Accepted By: @廖丹龙 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1662?initial=true
This commit is contained in:
@@ -10,6 +10,39 @@ from odoo.tools import OrderedSet
|
|||||||
# _get_surface_technics_purchase_ids
|
# _get_surface_technics_purchase_ids
|
||||||
class PurchaseOrder(models.Model):
|
class PurchaseOrder(models.Model):
|
||||||
_inherit = 'purchase.order'
|
_inherit = 'purchase.order'
|
||||||
|
production_count = fields.Integer(
|
||||||
|
"关联制造订单",
|
||||||
|
compute='_compute_workorder_count',
|
||||||
|
)
|
||||||
|
|
||||||
|
def action_view_production(self):
|
||||||
|
origins = [order.name for order in self.picking_ids]
|
||||||
|
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||||
|
if not production_id:
|
||||||
|
return
|
||||||
|
action = {
|
||||||
|
'res_model': 'mrp.production',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
}
|
||||||
|
if len(production_id) == 1:
|
||||||
|
action.update({
|
||||||
|
'view_mode': 'form',
|
||||||
|
'res_id': production_id.id,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
action.update({
|
||||||
|
'name': _("制造订单列表"),
|
||||||
|
'domain': [('id', 'in', production_id.ids)],
|
||||||
|
'view_mode': 'tree,form',
|
||||||
|
})
|
||||||
|
return action
|
||||||
|
|
||||||
|
|
||||||
|
def _compute_workorder_count(self):
|
||||||
|
for purchase in self:
|
||||||
|
origins = [order.name for order in purchase.picking_ids]
|
||||||
|
production_id = self.env['mrp.production'].search([('origin', 'in', origins)])
|
||||||
|
purchase.production_count = len(production_id)
|
||||||
def button_confirm(self):
|
def button_confirm(self):
|
||||||
super().button_confirm()
|
super().button_confirm()
|
||||||
workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id)])
|
workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id)])
|
||||||
|
|||||||
@@ -10,6 +10,18 @@
|
|||||||
<field name="related_product" optional="show"/>
|
<field name="related_product" optional="show"/>
|
||||||
<field name="part_number" optional="show"/>
|
<field name="part_number" optional="show"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//sheet//div[@class='oe_button_box']" position="inside">
|
||||||
|
<button class="oe_stat_button" name="action_view_production" type="object" icon="fa-wrench"
|
||||||
|
attrs="{'invisible': [('production_count', '=', 0)]}"
|
||||||
|
>
|
||||||
|
<div class="o_field_widget o_stat_info">
|
||||||
|
<span class="o_stat_value">
|
||||||
|
<field name="production_count"/>
|
||||||
|
</span>
|
||||||
|
<span class="o_stat_text">制造订单</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
Reference in New Issue
Block a user