优化采购和销售

This commit is contained in:
jinling.yang
2023-12-22 17:43:25 +08:00
parent 58d4b3813b
commit 93ce482d40
9 changed files with 252 additions and 47 deletions

View File

@@ -1 +1,2 @@
from . import sale_order_wizard
from . import purchase_order_wizard

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from odoo import models, api, fields
from odoo.exceptions import UserError
class PurchaseOrderWizard(models.TransientModel):
_name = 'purchase.order.wizard'
_description = '采购向导'
order_id = fields.Many2one('purchase.order')
# check_state = fields.Selection([('pass', '通过'), ('back', '退回')], '处理意见', default='pass')
check_audit = fields.Text('审核意见')
def submit(self):
self.order_id.check_status = 'approved'
self.order_id.remark = self.check_audit
def back(self):
if not self.check_audit:
raise UserError('请输入原因')
else:
self.order_id.write({'check_status': 'fail', 'remark': self.check_audit})
def confirm(self):
self.order_id.check_status = 'pending'

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="purchase_order_check_wizard_form_view">
<field name="name">purchase.order.check.wizard.form.view</field>
<field name="model">purchase.order.wizard</field>
<field name="arch" type="xml">
<form>
<field name="order_id" invisible="True"/>
<group>
<!-- <field name="check_state" widget="radio" options="{'horizontal': true}" required="True" string=""/>-->
<field name="check_audit" placeholder="原因.." nolabel="1" colspan="2"/>
</group>
<footer>
<button string="通过" name="submit" type="object" class="oe_highlight"/>
<button string="退回" name="back" type="object" class="btn btn-secondary"/>
<!-- <button string="提交" name="submit" type="object" class="oe_highlight"/>-->
<!-- <button string="取消" class="btn btn-secondary" special="cancel"/>-->
</footer>
</form>
</field>
</record>
<record id="action_purchase_order_check_wizard" model="ir.actions.act_window">
<field name="name">审核</field>
<field name="res_model">purchase.order.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.ui.view" id="purchase_order_submit_wizard_form_view">
<field name="name">purchase.order.submit.wizard.form.view</field>
<field name="model">purchase.order.wizard</field>
<field name="arch" type="xml">
<form>
<field name="order_id" invisible="True"/>
<div>
提交后不可更改,是否确定提交?
</div>
<footer>
<button string="确认" name="confirm" type="object" class="oe_highlight"/>
<button string="取消" class="btn btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_purchase_order_submit_wizard" model="ir.actions.act_window">
<field name="name">提交</field>
<field name="res_model">purchase.order.wizard</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>