[IMP] point_of_sale: Add serial number on pos invoice

When we make an invoice with the point of sale, we now include the serial numbers on the invoice template if the option is ticked.

closes odoo/odoo#59516

Task-id: 2349339
Related: odoo/upgrade#1830
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
Robin Heinz
2020-10-23 09:28:34 +00:00
committed by Pierre Masereel
parent 1b67affe7d
commit bc67e6bf55
12 changed files with 51 additions and 26 deletions
@@ -23,6 +23,29 @@ class AccountMove(models.Model):
for invoice in pos_invoices:
invoice.payment_state = 'paid'
def _get_invoiced_lot_values(self):
self.ensure_one()
lot_values = super(AccountMove, self)._get_invoiced_lot_values()
if self.state == 'draft':
return lot_values
for order in self.pos_order_ids:
for line in order.lines:
lots = line.pack_lot_ids or False
if lots:
for lot in lots:
lot_values.append({
'product_name': lot.product_id.name,
'quantity': line.qty if lot.product_id.tracking == 'lot' else 1.0,
'uom_name': line.product_uom_id.name,
'lot_name': lot.lot_name,
})
return lot_values
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
-1
View File
@@ -28,7 +28,6 @@ Preferences
'views/res_config_settings_views.xml',
'views/sale_stock_portal_template.xml',
'views/stock_production_lot_views.xml',
'views/report_invoice.xml',
'views/res_users_views.xml',
'report/report_stock_forecasted.xml',
'report/sale_order_report_templates.xml',
+4 -2
View File
@@ -26,8 +26,10 @@ class AccountMove(models.Model):
""" Get and prepare data to show a table of invoiced lot on the invoice's report. """
self.ensure_one()
res = super(AccountMove, self)._get_invoiced_lot_values()
if self.state == 'draft':
return []
return res
sale_orders = self.mapped('invoice_line_ids.sale_line_ids.order_id')
stock_move_lines = sale_orders.mapped('picking_ids.move_lines.move_line_ids')
@@ -86,7 +88,7 @@ class AccountMove(models.Model):
qties_per_lot[ml.lot_id] += ml.product_uom_id._compute_quantity(ml.qty_done, ml.product_id.uom_id)
for ml in incoming_sml:
qties_per_lot[ml.lot_id] -= ml.product_uom_id._compute_quantity(ml.qty_done, ml.product_id.uom_id)
lot_values = []
lot_values = res
for lot_id, qty in qties_per_lot.items():
if float_is_zero(qty, precision_rounding=lot_id.product_id.uom_id.rounding):
continue
@@ -9,8 +9,6 @@ class ResConfigSettings(models.TransientModel):
security_lead = fields.Float(related='company_id.security_lead', string="Security Lead Time", readonly=False)
group_display_incoterm = fields.Boolean("Incoterms", implied_group='sale_stock.group_display_incoterm')
group_lot_on_invoice = fields.Boolean("Display Lots & Serial Numbers on Invoices",
implied_group='sale_stock.group_lot_on_invoice')
use_security_lead = fields.Boolean(
string="Security Lead Time for Sales",
config_parameter='sale_stock.use_security_lead',
@@ -5,11 +5,6 @@
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="group_lot_on_invoice" model="res.groups">
<field name="name">Display Serial &amp; Lot Number on Invoices</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<data noupdate="1">
<!-- Stock Portal Access Rules -->
@@ -32,19 +32,6 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form"/>
<field name="arch" type="xml">
<div id="production_lot_info" position="inside">
<div class="col-12 col-lg-6 o_setting_box" attrs="{'invisible': [('group_stock_production_lot', '=', False)]}" id="group_lot_on_invoice">
<div class="o_setting_left_pane">
<field name="group_lot_on_invoice"/>
</div>
<div class="o_setting_right_pane">
<label for="group_lot_on_invoice"/>
<div class="text-muted">
Lots &amp; Serial numbers will appear on the invoice
</div>
</div>
</div>
</div>
<div id="warning_info" position="after">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
+1
View File
@@ -31,6 +31,7 @@ Dashboard / Reports for Warehouse Management includes:
'data/product_data.xml',
'views/product_views.xml',
'views/stock_quant_views.xml',
'views/report_invoice.xml',
'views/stock_valuation_layer_views.xml',
'wizard/stock_valuation_layer_revaluation_views.xml',
'report/report_stock_forecasted.xml',
@@ -210,6 +210,9 @@ class AccountMove(models.Model):
# Reconcile.
product_account_moves.reconcile()
def _get_invoiced_lot_values(self):
return []
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
@@ -9,3 +9,5 @@ class ResConfigSettings(models.TransientModel):
module_stock_landed_costs = fields.Boolean("Landed Costs",
help="Affect landed costs on reception operations and split them among products to update their cost price.")
group_lot_on_invoice = fields.Boolean("Display Lots & Serial Numbers on Invoices",
implied_group='stock_account.group_lot_on_invoice')
@@ -7,5 +7,9 @@
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
</odoo>
<record id="group_lot_on_invoice" model="res.groups">
<field name="name">Display Serial &amp; Lot Number on Invoices</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
</odoo>
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="sale_stock_report_invoice_document" inherit_id="account.report_invoice_document">
<template id="stock_account_report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//div[@id='total']" position="after">
<t t-set="lot_values" t-value="o._get_invoiced_lot_values()"/>
<t t-if="lot_values">
<br/>
<table groups="sale_stock.group_lot_on_invoice" class="table table-sm" style="width: 50%;" name="invoice_snln_table">
<table groups="stock_account.group_lot_on_invoice" class="table table-sm" style="width: 50%;" name="invoice_snln_table">
<thead>
<tr>
<th><span>Product</span></th>
@@ -26,6 +26,17 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box" attrs="{'invisible': [('group_stock_production_lot', '=', False)]}" id="group_lot_on_invoice">
<div class="o_setting_left_pane">
<field name="group_lot_on_invoice"/>
</div>
<div class="o_setting_right_pane">
<label for="group_lot_on_invoice"/>
<div class="text-muted">
Lots &amp; Serial numbers will appear on the invoice
</div>
</div>
</div>
</div>
</div>
</field>