[IMP] pre-commit: first run on whole repo
This commit is contained in:
@@ -3,20 +3,20 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Service Line Qty Update Purchase',
|
||||
'version': '12.0.1.0.0',
|
||||
'category': 'Tools',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Update delivery qty on service lines - Purchase module',
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': [
|
||||
'purchase',
|
||||
'service_line_qty_update_base',
|
||||
'purchase_reception_status',
|
||||
],
|
||||
'data': [
|
||||
'views/purchase_order.xml',
|
||||
],
|
||||
'installable': False,
|
||||
"name": "Service Line Qty Update Purchase",
|
||||
"version": "12.0.1.0.0",
|
||||
"category": "Tools",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Update delivery qty on service lines - Purchase module",
|
||||
"author": "Akretion",
|
||||
"website": "https://github.com/OCA/odoo-usability",
|
||||
"depends": [
|
||||
"purchase",
|
||||
"service_line_qty_update_base",
|
||||
"purchase_reception_status",
|
||||
],
|
||||
"data": [
|
||||
"views/purchase_order.xml",
|
||||
],
|
||||
"installable": False,
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ from odoo import api, fields, models
|
||||
|
||||
|
||||
class PurchaseOrder(models.Model):
|
||||
_inherit = 'purchase.order'
|
||||
_inherit = "purchase.order"
|
||||
|
||||
has_service = fields.Boolean(compute='_compute_has_service')
|
||||
has_service = fields.Boolean(compute="_compute_has_service")
|
||||
|
||||
@api.depends('order_line.product_id.type')
|
||||
@api.depends("order_line.product_id.type")
|
||||
def _compute_has_service(self):
|
||||
for order in self:
|
||||
has_service = False
|
||||
for l in order.order_line:
|
||||
if l.product_id.type == 'service':
|
||||
if l.product_id.type == "service":
|
||||
has_service = True
|
||||
break
|
||||
order.has_service = has_service
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2020 Akretion France (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="purchase_order_form" model="ir.ui.view">
|
||||
<field name="name">purchase.order.form</field>
|
||||
<field name="model">purchase.order</field>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||
<field name="inherit_id" ref="purchase.purchase_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<button name="action_view_invoice" position="after">
|
||||
<button name="%(service_line_qty_update_base.service_qty_update_action)d" type="action" string="Update Service Qty" attrs="{'invisible': ['|', '|', ('state', 'not in', ('purchase', 'done')), ('has_service', '=', False), ('reception_status', '=', 'received')]}" groups="purchase.group_purchase_user"/>
|
||||
<field name="has_service" invisible="1"/>
|
||||
<button
|
||||
name="%(service_line_qty_update_base.service_qty_update_action)d"
|
||||
type="action"
|
||||
string="Update Service Qty"
|
||||
attrs="{'invisible': ['|', '|', ('state', 'not in', ('purchase', 'done')), ('has_service', '=', False), ('reception_status', '=', 'received')]}"
|
||||
groups="purchase.group_purchase_user"
|
||||
/>
|
||||
<field name="has_service" invisible="1" />
|
||||
</button>
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='qty_received']" position="attributes">
|
||||
<xpath
|
||||
expr="//field[@name='order_line']/tree/field[@name='qty_received']"
|
||||
position="attributes"
|
||||
>
|
||||
<attribute name="readonly">1</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -4,59 +4,77 @@
|
||||
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.tools import float_compare
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools import float_compare
|
||||
|
||||
|
||||
class ServiceQtyUpdate(models.TransientModel):
|
||||
_inherit = 'service.qty.update'
|
||||
_inherit = "service.qty.update"
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super().default_get(fields_list)
|
||||
prec = self.env['decimal.precision'].precision_get('Product Unit of Measure')
|
||||
if self._context.get('active_model') == 'purchase.order' and self._context.get('active_id'):
|
||||
prec = self.env["decimal.precision"].precision_get("Product Unit of Measure")
|
||||
if self._context.get("active_model") == "purchase.order" and self._context.get(
|
||||
"active_id"
|
||||
):
|
||||
lines = []
|
||||
order = self.env['purchase.order'].browse(self._context['active_id'])
|
||||
for l in order.order_line.filtered(lambda x: x.product_id.type == 'service'):
|
||||
if float_compare(l.product_qty, l.qty_received, precision_digits=prec) > 0:
|
||||
lines.append((0, 0, {
|
||||
'purchase_line_id': l.id,
|
||||
'product_id': l.product_id.id,
|
||||
'name': l.name,
|
||||
'name_readonly': l.name,
|
||||
'order_qty': l.product_qty,
|
||||
'order_qty_readonly': l.product_qty,
|
||||
'pre_delivered_qty': l.qty_received,
|
||||
'pre_delivered_qty_readonly': l.qty_received,
|
||||
'uom_id': l.product_uom.id,
|
||||
}))
|
||||
order = self.env["purchase.order"].browse(self._context["active_id"])
|
||||
for l in order.order_line.filtered(
|
||||
lambda x: x.product_id.type == "service"
|
||||
):
|
||||
if (
|
||||
float_compare(l.product_qty, l.qty_received, precision_digits=prec)
|
||||
> 0
|
||||
):
|
||||
lines.append(
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"purchase_line_id": l.id,
|
||||
"product_id": l.product_id.id,
|
||||
"name": l.name,
|
||||
"name_readonly": l.name,
|
||||
"order_qty": l.product_qty,
|
||||
"order_qty_readonly": l.product_qty,
|
||||
"pre_delivered_qty": l.qty_received,
|
||||
"pre_delivered_qty_readonly": l.qty_received,
|
||||
"uom_id": l.product_uom.id,
|
||||
},
|
||||
)
|
||||
)
|
||||
if lines:
|
||||
res['line_ids'] = lines
|
||||
res["line_ids"] = lines
|
||||
else:
|
||||
raise UserError(_(
|
||||
"All service lines are fully received."))
|
||||
raise UserError(_("All service lines are fully received."))
|
||||
return res
|
||||
|
||||
|
||||
class ServiceQtyUpdateLine(models.TransientModel):
|
||||
_inherit = 'service.qty.update.line'
|
||||
_inherit = "service.qty.update.line"
|
||||
|
||||
purchase_line_id = fields.Many2one('purchase.order.line', string='Purchase Line', readonly=True)
|
||||
purchase_line_id = fields.Many2one(
|
||||
"purchase.order.line", string="Purchase Line", readonly=True
|
||||
)
|
||||
|
||||
def process_line(self):
|
||||
po_line = self.purchase_line_id
|
||||
if po_line:
|
||||
new_qty = po_line.qty_received + self.added_delivered_qty
|
||||
po_line.write({'qty_received': new_qty})
|
||||
po_line.write({"qty_received": new_qty})
|
||||
body = """
|
||||
<p>Received qty updated on service line <b>%s</b>:
|
||||
<ul>
|
||||
<li>Added received qty: <b>%s</b></li>
|
||||
<li>Total received qty: %s</li>
|
||||
</ul></p>
|
||||
""" % (self.name, self.added_delivered_qty, new_qty)
|
||||
""" % (
|
||||
self.name,
|
||||
self.added_delivered_qty,
|
||||
new_qty,
|
||||
)
|
||||
if self.comment:
|
||||
body += '<p>Comment: %s</p>' % self.comment
|
||||
body += "<p>Comment: %s</p>" % self.comment
|
||||
po_line.order_id.message_post(body=body)
|
||||
return super().process_line()
|
||||
|
||||
Reference in New Issue
Block a user