添加功能

This commit is contained in:
zhou
2025-08-08 17:36:43 +08:00
parent 729e6eee85
commit 768f8f8d76
6 changed files with 90 additions and 7 deletions
@@ -32,6 +32,27 @@ class PurchaseFixedAssets(models.Model):
name_title = fields.Char(default=_get_default_name_title, string="标题")
def end_approval(self):
for rec in self:
purchase_order = self.env['purchase.order'].create({
'partner_id': rec.partner_id.id,
'date_order': rec.date_order if rec.date_order else None,
'date_planned': rec.date_planned if rec.date_planned else None,
'company_id': rec.company_id.id,
'user_id': rec.user_id.id,
})
order_lines = []
for fixed_line in rec.fixed_ids:
if not fixed_line.product_id:
continue
order_lines.append((0, 0, {
'order_id': purchase_order.id,
'product_id': fixed_line.product_id.id,
'product_qty': fixed_line.number,
}))
if order_lines:
purchase_order.order_line = order_lines
class PurchaseOrderPayLine(models.Model):
_name = "purchase.order.pay.line"
@@ -55,5 +76,5 @@ class PurchaseFixedLine(models.Model):
brand = fields.Char(string="品牌")
specs = fields.Char(string="规格")
number = fields.Integer(string="数量")
unit_id = fields.Many2one('uom.uom', string="单位")
price = fields.Float(related='product_id.standard_price', string="单价")
unit_id = fields.Many2one(related='product_id.uom_id', string="单位")
price = fields.Float(related='product_id.standard_price', string="单价", stroe=True)
+29 -1
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models
from datetime import datetime
class PurchaseLowOrders(models.Model):
@@ -30,6 +31,33 @@ class PurchaseLowOrders(models.Model):
name_title = fields.Char(default=_get_default_name_title)
def end_approval(self):
for rec in self:
date_with_time = datetime.combine(
fields.Date.from_string(rec.date_application),
datetime.min.time().replace(hour=0)
)
purchase_order = self.env['purchase.order'].create({
'partner_id': rec.partyB.id,
'date_order': date_with_time,
'company_id': rec.company_id.id,
'user_id': rec.user_id.id,
})
order_lines = []
for low_line in rec.low_line_ids:
if not low_line.product_id:
continue
order_lines.append((0, 0, {
'order_id': purchase_order.id,
'product_id': low_line.product_id.id,
'product_qty': low_line.number,
'product_uom': low_line.unit_id.id,
'price_unit': low_line.price,
}))
if order_lines:
purchase_order.order_line = order_lines
class PurchaseLowLine(models.Model):
_name = 'purchase.low.line'
@@ -40,7 +68,7 @@ class PurchaseLowLine(models.Model):
brand = fields.Char(string="品牌")
specs = fields.Char(string="规格")
number = fields.Integer(string="数量")
unit_id = fields.Many2one('uom.uom', string="单位")
unit_id = fields.Many2one(related='product_id.uom_id', string="单位")
price = fields.Float(related='product_id.standard_price', string="单价")
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models
from datetime import datetime
class PurchaseServiceOrders(models.Model):
@@ -38,6 +39,30 @@ class PurchaseServiceOrders(models.Model):
name_title = fields.Char(default=_get_default_name_title)
def end_approval(self):
for rec in self:
date_with_time = datetime.combine(
fields.Date.from_string(rec.date_application),
datetime.min.time().replace(hour=0)
)
purchase_order = self.env['purchase.order'].create({
'partner_id': rec.partyB.id,
'date_order': date_with_time,
'company_id': rec.company_id.id,
'user_id': rec.user_id.id,
})
order_lines = []
for service_line in rec.service_line_ids:
if not service_line.product_id:
continue
order_lines.append((0, 0, {
'order_id': purchase_order.id,
'product_id': service_line.product_id.id,
}))
if order_lines:
purchase_order.order_line = order_lines
class PurchaseServiceLine(models.Model):
_name = 'purchase.service.line'
_description = '服务采购单明细'
@@ -46,7 +71,7 @@ class PurchaseServiceLine(models.Model):
product_id = fields.Many2one('product.product', string="服务项目")
frequency = fields.Char(string='频次')
fee = fields.Float(string="费用")
unit_id = fields.Many2one('uom.uom', string="单位")
unit_id = fields.Many2one(related='product_id.uom_id', string="单位")
partyB = fields.Many2one('res.partner', string="供应商")
price = fields.Float(related='product_id.standard_price', string="单价")
@@ -25,6 +25,9 @@
invisible="urgency_level != 'urgent'"/>
<widget name="web_ribbon" title="特级" bg_color="text-bg-danger"
invisible="urgency_level != 'emergency'"/>
<header>
<button name="end_approval" type="object" string="结束" dclass="oe_highlight"/>
</header>
<group col="3">
<group>
<field name="purchase_code" string="流水号" readonly="1"/>
@@ -50,7 +53,7 @@
<field name="state" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="user_id"/>
<field name="partner_id" domain="[('company_id', '=', company_id)]"/>
<field name="partner_id" domain="[('company_id', '=', company_id)]" required="1"/>
</group>
<group>
<field name="date_order"/>
@@ -26,6 +26,9 @@
invisible="urgency_level != 'urgent'"/>
<widget name="web_ribbon" title="特级" bg_color="text-bg-danger"
invisible="urgency_level != 'emergency'"/>
<header>
<button name="end_approval" type="object" string="结束" dclass="oe_highlight"/>
</header>
<group col="4">
<group>
<field name="code" string="流水号" readonly="1"/>
@@ -46,7 +49,7 @@
<field name="company_id" invisible="1"/>
<field name="department_id" invisible="1"/>
<field name="work_end" invisible="1"/>
<field name="partyB"/>
<field name="partyB" required="1" domain="[('company_id', '=', company_id)]"/>
<field name="reason_application"/>
<field name="date_application"/>
<field name="document_ids" widget="preview_many2many"/>
@@ -26,6 +26,9 @@
invisible="urgency_level != 'urgent'"/>
<widget name="web_ribbon" title="特级" bg_color="text-bg-danger"
invisible="urgency_level != 'emergency'"/>
<header>
<button name="end_approval" type="object" string="结束" dclass="oe_highlight"/>
</header>
<group col="4">
<group>
<field name="code" string="流水号" readonly="1"/>
@@ -47,7 +50,7 @@
<field name="department_id" invisible="1"/>
<field name="work_end" invisible="1"/>
<field name="service_content"/>
<field name="partyB"/>
<field name="partyB" required="1" domain="[('company_id', '=', company_id)]"/>
<field name="date_application"/>
<label for="service_start_date"/>
<div class="d-inline-flex w-100">