[IMP] pre-commit: first run on whole repo

This commit is contained in:
Kevin Khao
2021-11-26 18:54:38 +03:00
parent a04b8980e1
commit 167aefee13
289 changed files with 6020 additions and 4170 deletions

View File

@@ -3,16 +3,16 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Service Line Qty Update Base',
'version': '12.0.1.0.0',
'category': 'Tools',
'license': 'AGPL-3',
'summary': 'Update delivery qty on service lines - Base module',
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['product'],
'data': [
'wizard/service_qty_update_view.xml',
],
'installable': False,
"name": "Service Line Qty Update Base",
"version": "12.0.1.0.0",
"category": "Tools",
"license": "AGPL-3",
"summary": "Update delivery qty on service lines - Base module",
"author": "Akretion",
"website": "https://github.com/OCA/odoo-usability",
"depends": ["product"],
"data": [
"wizard/service_qty_update_view.xml",
],
"installable": False,
}

View File

@@ -4,60 +4,76 @@
from odoo import _, api, fields, models
from odoo.tools import float_compare, float_is_zero
import odoo.addons.decimal_precision as dp
from odoo.exceptions import UserError
from odoo.tools import float_compare
import odoo.addons.decimal_precision as dp
class ServiceQtyUpdate(models.TransientModel):
_name = 'service.qty.update'
_description = 'Wizard to update delivery qty on service lines'
_name = "service.qty.update"
_description = "Wizard to update delivery qty on service lines"
line_ids = fields.One2many('service.qty.update.line', 'parent_id', string="Lines")
line_ids = fields.One2many("service.qty.update.line", "parent_id", string="Lines")
def run(self):
self.ensure_one()
prec = self.env['decimal.precision'].precision_get('Product Unit of Measure')
prec = self.env["decimal.precision"].precision_get("Product Unit of Measure")
for line in self.line_ids:
if float_compare(line.post_delivered_qty, line.order_qty, precision_digits=prec) > 0:
raise UserError(_(
"On line '%s', the total delivered qty (%s) is superior to the ordered qty (%s).") % (line.name, line.post_delivered_qty, line.order_qty))
if (
float_compare(
line.post_delivered_qty, line.order_qty, precision_digits=prec
)
> 0
):
raise UserError(
_(
"On line '%s', the total delivered qty (%s) is superior to the ordered qty (%s)."
)
% (line.name, line.post_delivered_qty, line.order_qty)
)
fc_added = float_compare(line.added_delivered_qty, 0, precision_digits=prec)
if fc_added < 0:
raise UserError(_(
"On line '%s', the added quantity is negative.") % line.name)
raise UserError(
_("On line '%s', the added quantity is negative.") % line.name
)
if fc_added > 0:
line.process_line()
return True
class ServiceQtyUpdateLine(models.TransientModel):
_name = 'service.qty.update.line'
_description = 'Lines of the wizard that updates delivery qty on service lines'
_name = "service.qty.update.line"
_description = "Lines of the wizard that updates delivery qty on service lines"
parent_id = fields.Many2one(
'service.qty.update', string='Wizard', ondelete='cascade')
product_id = fields.Many2one('product.product', string='Product', readonly=True)
"service.qty.update", string="Wizard", ondelete="cascade"
)
product_id = fields.Many2one("product.product", string="Product", readonly=True)
name = fields.Char()
name_readonly = fields.Char(related='name', string='Description')
name_readonly = fields.Char(related="name", string="Description")
order_qty = fields.Float(
string='Order Qty',
digits=dp.get_precision('Product Unit of Measure'))
order_qty_readonly = fields.Float(related='order_qty', string='Product Unit of Measure')
pre_delivered_qty = fields.Float(
digits=dp.get_precision('Product Unit of Measure'))
pre_delivered_qty_readonly = fields.Float(related='pre_delivered_qty', string='Current Delivered Qty')
string="Order Qty", digits=dp.get_precision("Product Unit of Measure")
)
order_qty_readonly = fields.Float(
related="order_qty", string="Product Unit of Measure"
)
pre_delivered_qty = fields.Float(digits=dp.get_precision("Product Unit of Measure"))
pre_delivered_qty_readonly = fields.Float(
related="pre_delivered_qty", string="Current Delivered Qty"
)
added_delivered_qty = fields.Float(
string='Added Delivered Qty',
digits=dp.get_precision('Product Unit of Measure'))
string="Added Delivered Qty", digits=dp.get_precision("Product Unit of Measure")
)
post_delivered_qty = fields.Float(
compute='_compute_post_delivered_qty',
string='Total Delivered Qty',
digits=dp.get_precision('Product Unit of Measure'))
uom_id = fields.Many2one('uom.uom', string='UoM', readonly=True)
comment = fields.Char(string='Comment')
compute="_compute_post_delivered_qty",
string="Total Delivered Qty",
digits=dp.get_precision("Product Unit of Measure"),
)
uom_id = fields.Many2one("uom.uom", string="UoM", readonly=True)
comment = fields.Char(string="Comment")
@api.depends('pre_delivered_qty', 'added_delivered_qty')
@api.depends("pre_delivered_qty", "added_delivered_qty")
def _compute_post_delivered_qty(self):
for line in self:
line.post_delivered_qty = line.pre_delivered_qty + line.added_delivered_qty

View File

@@ -1,10 +1,9 @@
<?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>
@@ -15,23 +14,28 @@
<group name="main">
<field name="line_ids" nolabel="1">
<tree editable="bottom">
<field name="product_id"/>
<field name="name" invisible="0"/>
<field name="name_readonly"/>
<field name="order_qty" invisible="1"/>
<field name="order_qty_readonly"/>
<field name="pre_delivered_qty" invisible="1"/>
<field name="pre_delivered_qty_readonly"/>
<field name="added_delivered_qty"/>
<field name="post_delivered_qty"/>
<field name="uom_id" groups="uom.group_uom"/>
<field name="comment"/>
<field name="product_id" />
<field name="name" invisible="0" />
<field name="name_readonly" />
<field name="order_qty" invisible="1" />
<field name="order_qty_readonly" />
<field name="pre_delivered_qty" invisible="1" />
<field name="pre_delivered_qty_readonly" />
<field name="added_delivered_qty" />
<field name="post_delivered_qty" />
<field name="uom_id" groups="uom.group_uom" />
<field name="comment" />
</tree>
</field>
</group>
<footer>
<button name="run" type="object" string="Validate" class="btn-primary"/>
<button special="cancel" string="Cancel" class="btn-default"/>
<button
name="run"
type="object"
string="Validate"
class="btn-primary"
/>
<button special="cancel" string="Cancel" class="btn-default" />
</footer>
</form>
</field>