mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
MIG product_catch_weight For Odoo 12.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
'name': 'Product Catch Weight',
|
||||
'version': '11.0.1.0.0',
|
||||
'version': '12.0.1.0.0',
|
||||
'category': 'Warehouse',
|
||||
'depends': [
|
||||
'sale_stock',
|
||||
|
||||
@@ -8,7 +8,7 @@ class AccountInvoiceLine(models.Model):
|
||||
_inherit = 'account.invoice.line'
|
||||
|
||||
catch_weight = fields.Float(string='Catch Weight', digits=(10, 4), compute='_compute_price', store=True)
|
||||
catch_weight_uom_id = fields.Many2one('product.uom', related='product_id.catch_weight_uom_id')
|
||||
catch_weight_uom_id = fields.Many2one('uom.uom', related='product_id.catch_weight_uom_id')
|
||||
|
||||
@api.one
|
||||
@api.depends('price_unit', 'discount', 'invoice_line_tax_ids', 'quantity',
|
||||
|
||||
@@ -4,4 +4,4 @@ from odoo import api, fields, models
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
catch_weight_uom_id = fields.Many2one('product.uom', string='Catch Weight UOM')
|
||||
catch_weight_uom_id = fields.Many2one('uom.uom', string='Catch Weight UOM')
|
||||
|
||||
@@ -6,7 +6,7 @@ class StockProductionLot(models.Model):
|
||||
|
||||
catch_weight_ratio = fields.Float(string='Catch Weight Ratio', digits=(10, 6), compute='_compute_catch_weight_ratio')
|
||||
catch_weight = fields.Float(string='Catch Weight', digits=(10, 4))
|
||||
catch_weight_uom_id = fields.Many2one('product.uom', related='product_id.catch_weight_uom_id')
|
||||
catch_weight_uom_id = fields.Many2one('uom.uom', related='product_id.catch_weight_uom_id')
|
||||
|
||||
@api.depends('catch_weight')
|
||||
def _compute_catch_weight_ratio(self):
|
||||
@@ -22,7 +22,7 @@ class StockProductionLot(models.Model):
|
||||
class StockMove(models.Model):
|
||||
_inherit = 'stock.move'
|
||||
|
||||
product_catch_weight_uom_id = fields.Many2one('product.uom', related="product_id.catch_weight_uom_id")
|
||||
product_catch_weight_uom_id = fields.Many2one('uom.uom', related="product_id.catch_weight_uom_id")
|
||||
|
||||
def _prepare_move_line_vals(self, quantity=None, reserved_quant=None):
|
||||
vals = super(StockMove, self)._prepare_move_line_vals(quantity=quantity, reserved_quant=reserved_quant)
|
||||
@@ -40,9 +40,9 @@ class StockMoveLine(models.Model):
|
||||
|
||||
catch_weight_ratio = fields.Float(string='Catch Weight Ratio', digits=(10, 6), default=1.0)
|
||||
catch_weight = fields.Float(string='Catch Weight', digits=(10,4))
|
||||
catch_weight_uom_id = fields.Many2one('product.uom', string='Catch Weight UOM')
|
||||
catch_weight_uom_id = fields.Many2one('uom.uom', string='Catch Weight UOM')
|
||||
lot_catch_weight = fields.Float(related='lot_id.catch_weight')
|
||||
lot_catch_weight_uom_id = fields.Many2one('product.uom', related='product_id.catch_weight_uom_id')
|
||||
lot_catch_weight_uom_id = fields.Many2one('uom.uom', related='product_id.catch_weight_uom_id')
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
@@ -61,4 +61,4 @@ class StockQuant(models.Model):
|
||||
|
||||
lot_catch_weight_ratio = fields.Float(related='lot_id.catch_weight_ratio')
|
||||
lot_catch_weight = fields.Float(related='lot_id.catch_weight')
|
||||
lot_catch_weight_uom_id = fields.Many2one('product.uom', related='lot_id.catch_weight_uom_id')
|
||||
lot_catch_weight_uom_id = fields.Many2one('uom.uom', related='lot_id.catch_weight_uom_id')
|
||||
|
||||
@@ -12,8 +12,8 @@ class TestPicking(TransactionCase):
|
||||
self.nominal_weight = 50.0
|
||||
self.partner1 = self.env.ref('base.res_partner_2')
|
||||
self.stock_location = self.env.ref('stock.stock_location_stock')
|
||||
self.ref_uom_id = self.env.ref('product.product_uom_kgm')
|
||||
self.product_uom_id = self.env['product.uom'].create({
|
||||
self.ref_uom_id = self.env.ref('uom.product_uom_kgm')
|
||||
self.product_uom_id = self.env['uom.uom'].create({
|
||||
'name': '50 ref',
|
||||
'category_id': self.ref_uom_id.category_id.id,
|
||||
'uom_type': 'bigger',
|
||||
|
||||
@@ -25,21 +25,21 @@
|
||||
|
||||
|
||||
<template id="report_invoice_document_inherit" name="report_invoice_document_catch_weight" inherit_id="account.report_invoice_document">
|
||||
<xpath expr="//thead/tr/th[4]" position="after">
|
||||
<xpath expr="//table[@name='invoice_line_table']/thead/tr/th[4]" position="after">
|
||||
<t t-if="o.invoice_line_ids.filtered(lambda l: l.catch_weight_uom_id)">
|
||||
<th class="text-right">Catch Weight</th>
|
||||
<th class="text-right">CW Unit Price</th>
|
||||
</t>
|
||||
</xpath>
|
||||
<xpath expr="//tbody/tr[1]/td[4]" position="after">
|
||||
<t t-if="o.invoice_line_ids.filtered(lambda l: l.catch_weight_uom_id)">
|
||||
<t t-if="l.catch_weight_uom_id">
|
||||
<xpath expr="//tbody[hasclass('invoice_tbody')]/t[2]/tr/t/td[4]" position="after">
|
||||
<t t-if="o.invoice_line_ids.filtered(lambda line: line.catch_weight_uom_id)">
|
||||
<t t-if="line.catch_weight_uom_id">
|
||||
<td class="text-right">
|
||||
<strong t-field="l.catch_weight"/>
|
||||
<span t-field="l.catch_weight_uom_id"/>
|
||||
<strong t-field="line.catch_weight"/>
|
||||
<span t-field="line.catch_weight_uom_id"/>
|
||||
<hr style="padding: 0; margin: 0;"/>
|
||||
<t t-if="o.type in ('out_invoice', 'out_refund')" t-set="lots" t-value="l.sale_line_ids.mapped('move_ids.move_line_ids.lot_id')"/>
|
||||
<t t-else="" t-set="lots" t-value="l.purchase_line_id.mapped('move_ids.move_line_ids.lot_id')"/>
|
||||
<t t-if="o.type in ('out_invoice', 'out_refund')" t-set="lots" t-value="line.sale_line_ids.mapped('move_ids.move_line_ids.lot_id')"/>
|
||||
<t t-else="" t-set="lots" t-value="line.purchase_line_id.mapped('move_ids.move_line_ids.lot_id')"/>
|
||||
<ul class="list-unstyled">
|
||||
<li t-foreach="lots" t-as="lot">
|
||||
<span t-field="lot.name"/>: <span t-field="lot.catch_weight"/>
|
||||
@@ -47,9 +47,9 @@
|
||||
</ul>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-esc="'{:0.2f}'.format(l.uom_id._compute_price(l.price_unit, l.catch_weight_uom_id))"/>
|
||||
<span t-esc="'{:0.2f}'.format(line.uom_id._compute_price(line.price_unit, line.catch_weight_uom_id))"/>
|
||||
/
|
||||
<span t-field="l.catch_weight_uom_id"/>
|
||||
<span t-field="line.catch_weight_uom_id"/>
|
||||
</td>
|
||||
</t>
|
||||
<t t-else="">
|
||||
@@ -57,10 +57,9 @@
|
||||
<td/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</xpath>
|
||||
<xpath expr="//tbody/tr[2]/td[4]" position="after">
|
||||
<t t-if="o.invoice_line_ids.filtered(lambda l: l.catch_weight_uom_id)">
|
||||
<xpath expr="//tbody[hasclass('invoice_tbody')]/t[2]/t[3]/tr/td" position="after">
|
||||
<t t-if="o.invoice_line_ids.filtered(lambda line: line.catch_weight_uom_id)">
|
||||
<td/>
|
||||
<td/>
|
||||
</t>
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_view_picking_internal_search_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.view.picking.internal.search.inherit</field>
|
||||
<record id="view_picking_internal_search_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.picking.internal.search.inherit</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_internal_search" />
|
||||
<field name="arch" type="xml">
|
||||
@@ -61,8 +61,9 @@
|
||||
<filter name="has_catch_weight" string="Has Catch Weight" domain="[('has_catch_weight','=',True)]" help="Pickings with Catch Weight"/>
|
||||
</xpath>
|
||||
<xpath expr="//group/filter[@name='picking_type']" position="after">
|
||||
<filter string="Has Catch Weight" domain="[]" context="{'group_by':'has_catch_weight'}"/>
|
||||
<filter name="has_catch_weight" string="Has Catch Weight" domain="[]" context="{'group_by':'has_catch_weight'}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user