采购到货通知需求更改
This commit is contained in:
2
sf_purchase_arrival_inform/wizard/__init__.py
Normal file
2
sf_purchase_arrival_inform/wizard/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import purchase_confirm_wizard
|
||||
|
||||
64
sf_purchase_arrival_inform/wizard/purchase_confirm_wizard.py
Normal file
64
sf_purchase_arrival_inform/wizard/purchase_confirm_wizard.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class PurchaseConfirmWizard(models.TransientModel):
|
||||
_name = 'purchase.confirm.wizard'
|
||||
_description = '采购订单确认向导'
|
||||
|
||||
purchase_order_id = fields.Many2one('purchase.order', string='采购订单', required=True)
|
||||
line_ids = fields.One2many('purchase.confirm.wizard.line', 'wizard_id', string='产品明细')
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
"""创建向导时自动生成产品明细"""
|
||||
records = super().create(vals_list)
|
||||
|
||||
for record in records:
|
||||
if record.purchase_order_id:
|
||||
# 自动创建产品明细行
|
||||
line_data = []
|
||||
for line in record.purchase_order_id.order_line:
|
||||
line_data.append({
|
||||
'wizard_id': record.id,
|
||||
'product_id': line.product_id.id,
|
||||
'product_name': line.product_id.name,
|
||||
'product_qty': line.product_qty,
|
||||
'product_uom': line.product_uom.name,
|
||||
'uom_rounding': line.product_uom.rounding,
|
||||
})
|
||||
|
||||
if line_data:
|
||||
self.env['purchase.confirm.wizard.line'].create(line_data)
|
||||
|
||||
return records
|
||||
|
||||
def action_confirm(self):
|
||||
"""确认采购订单"""
|
||||
if self.purchase_order_id:
|
||||
# 调用原始的确认方法
|
||||
self.purchase_order_id._execute_original_confirm()
|
||||
|
||||
# 返回关闭向导并刷新采购订单页面
|
||||
return {
|
||||
'type': 'ir.actions.act_window_close',
|
||||
'infos': {
|
||||
'title': _('成功'),
|
||||
'message': _('采购订单已确认成功!'),
|
||||
}
|
||||
}
|
||||
|
||||
def action_cancel(self):
|
||||
"""取消操作"""
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
class PurchaseConfirmWizardLine(models.TransientModel):
|
||||
_name = 'purchase.confirm.wizard.line'
|
||||
_description = '采购订单确认向导明细'
|
||||
|
||||
wizard_id = fields.Many2one('purchase.confirm.wizard', string='向导', ondelete='cascade')
|
||||
product_id = fields.Many2one('product.product', string='产品')
|
||||
product_name = fields.Char(string='产品名称')
|
||||
product_qty = fields.Float(string='数量')
|
||||
product_uom = fields.Char(string='单位')
|
||||
uom_rounding = fields.Float(string='舍入精度')
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- 采购订单确认向导视图 -->
|
||||
<record id="purchase_confirm_wizard_form" model="ir.ui.view">
|
||||
<field name="name">purchase.confirm.wizard.form</field>
|
||||
<field name="model">purchase.confirm.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="采购订单确认">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<strong>确认提示:</strong>以下产品数量将按单位舍入精度向上取整处理,请核实后确认是否继续。
|
||||
</div>
|
||||
|
||||
<group>
|
||||
<field name="purchase_order_id" readonly="1"/>
|
||||
</group>
|
||||
|
||||
<separator string="产品明细信息"/>
|
||||
|
||||
<field name="line_ids" readonly="1" nolabel="1" widget="one2many_list">
|
||||
<tree decoration-info="True" create="false" edit="false">
|
||||
<field name="product_name" string="产品名称" width="40%"/>
|
||||
<field name="product_qty" string="订购数量" width="20%"/>
|
||||
<field name="product_uom" string="计量单位" width="20%"/>
|
||||
<field name="uom_rounding" string="舍入精度" widget="float" digits="[16,6]" width="20%"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
<footer>
|
||||
<button name="action_confirm" string="确认订单" type="object" class="btn-primary"/>
|
||||
<button name="action_cancel" string="取消" type="object" class="btn-secondary"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user