Accept Merge Request #2040: (hotfix/解决采购申请bug -> develop)

Merge Request: 解决创建采购申请报错

Created By: @胡尧
Accepted By: @胡尧
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2040?initial=true
This commit is contained in:
胡尧
2025-04-23 14:21:27 +08:00
committed by Coding
7 changed files with 135 additions and 118 deletions

View File

@@ -28,6 +28,10 @@ class PurchaseRequest(models.Model):
origin_context.pop('search_default_draft')
action['context'] = origin_context
return action
def button_in_progress(self):
return self.write({"state": "in_progress"})
class PurchaseRequestLine(models.Model):
_inherit = 'purchase.request.line'

View File

@@ -100,6 +100,23 @@ class PurchaseRequestLineMakePurchaseOrder(models.TransientModel):
def check_group(self, request_lines):
# 去掉合并必须同一采购组的限制
pass
def _post_process_po_line(self, item, po_line, new_pr_line):
self.ensure_one()
line = item.line_id
# TODO: Check propagate_uom compatibility:
new_qty = self.env["purchase.request.line"]._calc_new_qty(
line, po_line=po_line, new_pr_line=new_pr_line
)
po_line.product_qty = new_qty
# The quantity update triggers a compute method that alters the
# unit price (which is what we want, to honor graduate pricing)
# but also the scheduled date which is what we don't want.
date_required = line.date_required
po_line.date_planned = datetime(
date_required.year, date_required.month, date_required.day
)
class PurchaseRequestLineMakePurchaseOrderItem(models.TransientModel):

View File

@@ -1,26 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_delivery_record_form_inherit_sf" model="ir.ui.view">
<field name="name">delivery.record.form.inherit.sf</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="arch" type="xml">
<xpath expr="//page[last()-3]" position="before">
<!-- <page string="下发记录" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>-->
<page string="下发记录" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "HDR")]}'>
<field name="delivery_records">
<tree create="false">
<field name="delivery_type"/>
<field name="delivery_time"/>
<field name="influence_record"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>
<!-- <record id="seqence_b_purchase_order" model='ir.sequence'> -->
<!-- <field name='name'>Purchase Order</field> -->
<!-- <field name='code'>sf_machine_connect.delivery.record</field> -->

View File

@@ -3,9 +3,9 @@
<record id="view_machine_info_form_inherit_sf" model="ir.ui.view">
<field name="name">machine.info.form.inherit.sf</field>
<field name="model">mrp.workorder</field>
<field name="inherit_id" ref="mrp.mrp_production_workorder_form_view_inherit"/>
<field name="inherit_id" ref="sf_manufacturing.view_mrp_production_workorder_tray_form_inherit_sf"/>
<field name="arch" type="xml">
<xpath expr="//page[last()-3]" position="before">
<xpath expr="//page[@name='CMR']" position="after">
<page string="机床信息" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "MTI")]}'>
<group string="机床信息">
<group>
@@ -33,6 +33,15 @@
</group>
</group>
</page>
<page string="下发记录" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "HDR")]}'>
<field name="delivery_records">
<tree create="false">
<field name="delivery_type"/>
<field name="delivery_time"/>
<field name="influence_record"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>

View File

@@ -1,57 +1,72 @@
<odoo>
<data noupdate="1">
<record model="sf.work.individuation.page" id="sf_work_individuation_page_1">
<field name="code">PTD</field>
<field name="name">后置三元检测</field>
</record>
<data noupdate="0">
<record model="sf.work.individuation.page" id="sf_work_individuation_page_2">
<field name="code">WCP</field>
<field name="name">工件装夹</field>
<field name="sequence">10</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_3">
<field name="code">ITD_PP</field>
<field name="name">前置三元检测定位参数</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_4">
<field name="code">2D_MD</field>
<field name="name">2D加工图纸</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_5">
<field name="code">QIS</field>
<field name="name">质检标准</field>
<field name="sequence">20</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_6">
<field name="code">WD</field>
<field name="name">工件配送</field>
<field name="sequence">30</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_9">
<field name="code">CNC_P</field>
<field name="name">CNC程序</field>
<field name="sequence">40</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_10">
<field name="code">CMM_P</field>
<field name="name">CMM程序</field>
<field name="sequence">50</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_11">
<field name="code">MTI</field>
<field name="name">机床信息</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_12">
<field name="code">HDR</field>
<field name="name">下发记录</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_13">
<field name="code">ER</field>
<field name="name">异常记录</field>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_1">
<field name="code">PTD</field>
<field name="name">后置三元检测</field>
<field name="sequence">60</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_14">
<field name="code">DCP</field>
<field name="name">解除装夹</field>
<field name="sequence">70</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_4">
<field name="code">2D_MD</field>
<field name="name">2D加工图纸</field>
<field name="sequence">80</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_5">
<field name="code">QIS</field>
<field name="name">质检标准</field>
<field name="sequence">90</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_15">
<field name="code">CMR</field>
<field name="name">开料要求</field>
<field name="sequence">100</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_11">
<field name="code">MTI</field>
<field name="name">机床信息</field>
<field name="sequence">110</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_12">
<field name="code">HDR</field>
<field name="name">下发记录</field>
<field name="sequence">120</field>
</record>
<record model="sf.work.individuation.page" id="sf_work_individuation_page_13">
<field name="code">ER</field>
<field name="name">异常记录</field>
<field name="sequence">130</field>
</record>
<!-- 原生页签先不进行配置 -->
<!-- <record model="sf.work.individuation.page" id="sf_work_individuation_page_7">-->

View File

@@ -139,6 +139,8 @@ class ResMrpRoutingWorkcenter(models.Model):
class WorkIndividuationPage(models.Model):
_name = 'sf.work.individuation.page'
_order = 'sequence'
code = fields.Char('编号')
name = fields.Char('名称')
sequence = fields.Integer('序号')

View File

@@ -237,22 +237,6 @@
<!-- string="返工"-->
<!-- attrs='{"invisible": [("rework_flag","=",True)]}' confirm="是否返工"/>-->
</xpath>
<xpath expr="//page[1]" position="before">
<page string="开料要求" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "CMR")]}'>
<group>
<group>
<field name="product_tmpl_id_materials_id" widget="many2one"/>
<field name="product_tmpl_id_materials_type_id" widget="many2one"/>
</group>
<group>
<field name="product_tmpl_id_length"/>
<field name="product_tmpl_id_width"/>
<field name="product_tmpl_id_height"/>
</group>
</group>
</page>
</xpath>
<xpath expr="//label[1]" position="before">
<!-- -->
<field name="production_id" invisible="0"/>
@@ -336,6 +320,8 @@
<xpath expr="//page[1]" position="before">
<field name="results" invisible="1"/>
<field name="individuation_page_list" invisible="1"/>
<page string="工件装夹" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "WCP")]}'>
<group>
<!-- <field name="_barcode_scanned" widget="barcode_handler"/> -->
@@ -514,7 +500,6 @@
<field name='X_deviation_angle' readonly="1"/>
</group>
</page>
<page string="工件配送" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "WD")]}'>
<field name="workpiece_delivery_ids">
<tree editable="bottom">
@@ -534,58 +519,6 @@
</tree>
</field>
</page>
</xpath>
<xpath expr="//form//header" position="inside">
<button type="object" class="oe_highlight jikimo_button_confirm" name="get_three_check_datas"
string="获取数据"
attrs='{"invisible": ["|", ("state","!=","progress"), ("routing_type","!=","装夹预调")]}'/>
</xpath>
<!-- =====原生页签,暂时不进行配置===== -->
<!-- <xpath expr="//page[@name='components']" position="attributes">-->
<!-- <attribute name="attrs">{"invisible": ["!", ("individuation_page_list", "ilike", "ML")]}</attribute>-->
<!-- </xpath>-->
<!-- <xpath expr="//page[@name='time_tracking']" position="attributes">-->
<!-- <attribute name="attrs">{"invisible": ["!", ("individuation_page_list", "ilike", "TT")]}</attribute>-->
<!-- </xpath>-->
<!-- ============================= -->
<xpath expr="//page[1]" position="before">
<field name="results" invisible="1"/>
<field name="individuation_page_list" invisible="1"/>
<page string="后置三元检测" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "PTD")]}'>
<group>
<field name="test_results"
attrs='{"readonly":["&amp;","|",("state","!=","to be detected"), "|",("routing_type","=","CNC加工"),("is_inspect", "=", True),("state","in",["done","rework"])],
"invisible":[("results","!=",False)]}'/>
<!-- <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>-->
<!-- <field name="is_fetchcnc"-->
<!-- attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>-->
<field name="reason"
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")],"readonly":[("state","in",("done", "rework"))]}'/>
<field name="detailed_reason"
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")],"readonly":[("state","in",("done", "rework"))]}'/>
<!-- <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>-->
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
widget="pdf_viewer" readonly="1"/>
</group>
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
<!-- <button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"-->
<!-- string="检测确认"-->
<!-- attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>-->
<!-- </div>-->
</page>
<page string="2D加工图纸" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "2D_MD")]}'>
<field name="machining_drawings" widget="adaptive_viewer"/>
</page>
<page string="质检标准" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "QIS")]}'>
<field name="quality_standard" widget="adaptive_viewer"/>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="CNC程序" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "CNC_P")]}'>
<field name="cnc_ids" widget="one2many" string="工作程序" default_order="sequence_number,id"
readonly="0">
@@ -621,8 +554,28 @@
</tree>
</field>
</page>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="后置三元检测" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "PTD")]}'>
<group>
<field name="test_results"
attrs='{"readonly":["&amp;","|",("state","!=","to be detected"), "|",("routing_type","=","CNC加工"),("is_inspect", "=", True),("state","in",["done","rework"])],
"invisible":[("results","!=",False)]}'/>
<!-- <field name="is_remanufacture" attrs='{"invisible":[("test_results","!=","报废")]}'/>-->
<!-- <field name="is_fetchcnc"-->
<!-- attrs='{"invisible":["|",("test_results","=","合格"),("is_remanufacture","=",False)]}'/>-->
<field name="reason"
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")],"readonly":[("state","in",("done", "rework"))]}'/>
<field name="detailed_reason"
attrs='{"required":[("test_results","!=","合格")],"invisible":[("test_results","=","合格")],"readonly":[("state","in",("done", "rework"))]}'/>
<!-- <field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>-->
<field name="detection_report" attrs='{"invisible":[("results","!=",False)]}'
widget="pdf_viewer" readonly="1"/>
</group>
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
<!-- <button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"-->
<!-- string="检测确认"-->
<!-- attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>-->
<!-- </div>-->
</page>
<page string="解除装夹" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "DCP")]}'>
<!-- <field name="tray_id" readonly="1"/>-->
<!-- <div class="col-12 col-lg-6 o_setting_box">-->
@@ -636,7 +589,45 @@
<!-- </div>-->
</page>
<page string="2D加工图纸" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "2D_MD")]}'>
<field name="machining_drawings" widget="adaptive_viewer"/>
</page>
<page string="质检标准" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "QIS")]}'>
<field name="quality_standard" widget="adaptive_viewer"/>
</page>
<page name="CMR" string="开料要求" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "CMR")]}'>
<group>
<group>
<field name="product_tmpl_id_materials_id" widget="many2one"/>
<field name="product_tmpl_id_materials_type_id" widget="many2one"/>
</group>
<group>
<field name="product_tmpl_id_length"/>
<field name="product_tmpl_id_width"/>
<field name="product_tmpl_id_height"/>
</group>
</group>
</page>
</xpath>
<xpath expr="//form//header" position="inside">
<button type="object" class="oe_highlight jikimo_button_confirm" name="get_three_check_datas"
string="获取数据"
attrs='{"invisible": ["|", ("state","!=","progress"), ("routing_type","!=","装夹预调")]}'/>
</xpath>
<!-- =====原生页签,暂时不进行配置===== -->
<!-- <xpath expr="//page[@name='components']" position="attributes">-->
<!-- <attribute name="attrs">{"invisible": ["!", ("individuation_page_list", "ilike", "ML")]}</attribute>-->
<!-- </xpath>-->
<!-- <xpath expr="//page[@name='time_tracking']" position="attributes">-->
<!-- <attribute name="attrs">{"invisible": ["!", ("individuation_page_list", "ilike", "TT")]}</attribute>-->
<!-- </xpath>-->
<!-- ============================= -->
<!-- <xpath expr="//form//sheet//group//group//div[1]" position="after">-->
<!-- <label for="date_start" string="实际加工时间"/>-->
<!-- <div class="oe_inline">-->