Skip to content

Commit

Permalink
[IMP] l10n_br_delivery_picking_label: print parcially
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Amaral committed Sep 19, 2024
1 parent 4083062 commit 909f286
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 14 deletions.
2 changes: 2 additions & 0 deletions l10n_br_delivery_picking_label/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import wizards
from . import models
3 changes: 3 additions & 0 deletions l10n_br_delivery_picking_label/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"l10n_br_delivery_nfe",
],
"data": [
"security/ir.model.access.csv",
"views/stock_picking.xml",
"wizards/delivery_picking_label_wizard.xml",
"report/report_delivery_picking_label.xml",
"data/paperformat.xml",
"data/report_delivery_picking_label.xml",
Expand Down
1 change: 1 addition & 0 deletions l10n_br_delivery_picking_label/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_picking
23 changes: 23 additions & 0 deletions l10n_br_delivery_picking_label/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockPicking(models.Model):

_inherit = "stock.picking"

first_volume = fields.Integer()
last_volume = fields.Integer()

def action_partially_print(self):
action = {
"type": "ir.actions.act_window",
"name": "Delivery Picking Label Wizard",
"res_model": "delivery.picking.label.wizard",
"view_mode": "form",
"context": "{}",
"target": "new",
}
return action
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,36 @@
<!-- <t t-call="web.html_container"> -->
<t t-call="web.basic_layout">
<t t-foreach="docs" t-as="picking">
<t t-foreach="range(picking.number_of_volumes)" t-as="volume">
<div class="page" style="page-break-after: always; border: 0 solid black; height: 61mm;" >
<div style="font-size: 15px; padding: 0; border: 0 solid black; height: 41mm;">
<p><span t-field="picking.partner_id.legal_name" style="margin: 0;" /></p>
<t
t-set="number_of_volumes"
t-value="picking.last_volume - picking.first_volume + 1"
/>
<t t-foreach="range(number_of_volumes)" t-as="volume">
<div
class="page"
style="page-break-after: always; border: 0 solid black; height: 61mm;"
>
<div
style="font-size: 15px; padding: 0; border: 0 solid black; height: 41mm;"
>
<p><span
t-field="picking.partner_id.legal_name"
style="margin: 0;"
/></p>
</div>
<p>NF-E <span
t-field="picking.document_serie"
/> <span t-field="picking.document_number" /></p>
<t t-set="volume_display" t-value="volume + 1" />
<p style="text-align: right;"><span t-esc="volume_display" />/<span
t-field="picking.number_of_volumes"
<p>NF-E <span t-field="picking.document_serie" /> <span
t-field="picking.document_number"
/></p>
<t
t-set="volume_display"
t-value="volume + picking.first_volume"
/>
<p style="text-align: right;"><span
t-esc="volume_display"
/>/<span t-field="picking.number_of_volumes" /></p>
<p style="text-align: right;"><span
t-field="picking.carrier_id"
/></p>
<p style="text-align: right;"><span t-field="picking.carrier_id" /></p>
</div>
</t>
</t>
Expand Down
2 changes: 2 additions & 0 deletions l10n_br_delivery_picking_label/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_delivery_picking_label_wizard_user,access_delivery_picking_label_wizard_user,model_delivery_picking_label_wizard,stock.group_stock_user,1,1,1,1
22 changes: 22 additions & 0 deletions l10n_br_delivery_picking_label/views/stock_picking.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 KMEE
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_picking_form" model="ir.ui.view">
<field
name="name"
>stock.picking.form (in l10n_br_delivery_picking_label)</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<xpath expr="//button[@name='action_cancel']" position="after">
<button
name="action_partially_print"
string="Partially Print"
type="object"
attrs="{'invisible': [('number_of_volumes','in',[0, None, False])]}"
/>
</xpath>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions l10n_br_delivery_picking_label/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import delivery_picking_label_wizard
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2024 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class DeliveryPickingLabelWizard(models.TransientModel):

_name = "delivery.picking.label.wizard"

first_volume = fields.Integer(string="First Volume", default=1)
last_volume = fields.Integer(string="Last Volume")
picking_id = fields.Many2one(
comodel_name="stock.picking",
default=lambda self: self.env.context.get("active_id"),
)

def print(self):
picking = self.env["stock.picking"].browse(self.env.context.get("active_id"))
vals = {
"first_volume": self.first_volume,
"last_volume": self.last_volume,
}
picking.write(vals)
return self.env.ref(
"l10n_br_delivery_picking_label.report_delivery_picking_label"
).report_action([])

@api.onchange("picking_id")
def _onchange_picking_id(self):
self.last_volume = self.picking_id.number_of_volumes

@api.onchange("first_volume")
def _onchange_first_volume(self):
if self.first_volume < 1:
self.first_volume = 1

if self.first_volume > self.last_volume:
self.first_volume = self.last_volume

@api.onchange("last_volume")
def _onchange_last_volume(self):
if self.last_volume > self.picking_id.number_of_volumes:
self.last_volume = self.picking_id.number_of_volumes

if self.last_volume < self.first_volume:
self.last_volume = self.first_volume
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 KMEE
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="delivery_picking_label_wizard_form_view">
<field
name="name"
>delivery.picking.label.wizard.form (in l10n_br_delivery_picking_label)</field>
<field name="model">delivery.picking.label.wizard</field>
<field name="arch" type="xml">
<form string="Delivery Picking Label Wizard">
<group>
<field name="first_volume" />
<field name="last_volume" />
<field name="picking_id" invisible="1" />
</group>
<footer>
<button
name="print"
string="OK"
class="btn-primary"
type="object"
/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>

</odoo>
7 changes: 7 additions & 0 deletions l10n_br_di/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Declaração de Importação</title>
<style type="text/css">

/*
:Author: David Goodger ([email protected])
Expand Down
7 changes: 4 additions & 3 deletions sale_enforce_commercial_partner/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down

0 comments on commit 909f286

Please sign in to comment.