Browse Source

[MIG][12.0] partner_label

12.0
Holger Brunn 4 years ago
parent
commit
810a85d67f
  1. 3
      partner_label/__init__.py
  2. 8
      partner_label/__manifest__.py
  3. 5
      partner_label/models/__init__.py
  4. 7
      partner_label/models/res_company.py
  5. 27
      partner_label/models/res_config_settings.py
  6. 46
      partner_label/reports/res_partner.xml
  7. 3
      partner_label/tests/__init__.py
  8. 14
      partner_label/tests/test_partner_label.py
  9. 78
      partner_label/views/base_config_settings.xml

3
partner_label/__init__.py

@ -1,4 +1 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

8
partner_label/__manifest__.py

@ -1,16 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Copyright 2019 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Partner labels",
"version": "10.0.1.0.0",
"version": "12.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Base",
"summary": "Print partner labels",
"depends": [
'base_setup',
'report',
],
"data": [
"views/base_config_settings.xml",

5
partner_label/models/__init__.py

@ -1,5 +1,2 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_company
from . import base_config_settings
from . import res_config_settings

7
partner_label/models/res_company.py

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import fields, models
# Copyright 2017-2019 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ResCompany(models.Model):

27
partner_label/models/base_config_settings.py → partner_label/models/res_config_settings.py

@ -1,36 +1,38 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
# Copyright 2017-2019 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class BaseConfigSettings(models.TransientModel):
_inherit = 'base.config.settings'
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
partner_labels_width = fields.Float(
related='company_id.partner_labels_width', required=True,
readonly=False,
)
partner_labels_height = fields.Float(
related='company_id.partner_labels_height', required=True,
readonly=False,
)
partner_labels_padding = fields.Float(
related='company_id.partner_labels_padding', required=True,
readonly=False,
)
partner_labels_margin_top = fields.Float(
related='company_id.partner_labels_margin_top',
required=True,
required=True, readonly=False,
)
partner_labels_margin_bottom = fields.Float(
related='company_id.partner_labels_margin_bottom',
required=True,
required=True, readonly=False,
)
partner_labels_margin_left = fields.Float(
related='company_id.partner_labels_margin_left',
required=True,
required=True, readonly=False,
)
partner_labels_margin_right = fields.Float(
related='company_id.partner_labels_margin_right',
required=True,
required=True, readonly=False,
)
partner_labels_paperformat_id = fields.Many2one(
'report.paperformat', string='Paperformat', required=True,
@ -57,7 +59,8 @@ class BaseConfigSettings(models.TransientModel):
@api.multi
def action_partner_labels_preview(self):
return self.env['report'].get_action(
return self.env.ref(
'partner_label.report_res_partner_label'
).report_action(
self.env['res.partner'].search([], limit=100),
'partner_label.view_res_partner_label',
)

46
partner_label/reports/res_partner.xml

@ -1,39 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="view_res_partner_label">
<t t-raw="'&lt;base href=%s&gt;' % base_url"/>
&lt;!DOCTYPE html&gt;
<html>
<head>
<meta charset="utf-8"/>
</head>
<body class="container">
<div class="page">
<t t-foreach="docs.with_context(show_address=True)" t-as="this">
<div t-attf-style="height: {{this.company_id.partner_labels_height}}mm;
width: {{this.company_id.partner_labels_width}}mm;
padding: {{this.company_id.partner_labels_padding}}mm;
margin-top: {{this.company_id.partner_labels_margin_top}}mm;
margin-bottom: {{this.company_id.partner_labels_margin_bottom}}mm;
margin-left: {{this.company_id.partner_labels_margin_left}}mm;
margin-right: {{this.company_id.partner_labels_margin_right}}mm;
display: inline-block;
overflow: hidden;
float:left;
page-break-inside: avoid;">
<address t-field="this.self"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'/>
</div>
</t>
<t t-call="web.basic_layout">
<t t-foreach="docs.with_context(show_address=True)" t-as="this">
<div t-attf-style="height: {{this.company_id.partner_labels_height}}mm;
width: {{this.company_id.partner_labels_width}}mm;
padding: {{this.company_id.partner_labels_padding}}mm;
margin-top: {{this.company_id.partner_labels_margin_top}}mm;
margin-bottom: {{this.company_id.partner_labels_margin_bottom}}mm;
margin-left: {{this.company_id.partner_labels_margin_left}}mm;
margin-right: {{this.company_id.partner_labels_margin_right}}mm;
display: inline-block;
overflow: hidden;
float:left;
page-break-inside: avoid;">
<address t-field="this.self"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'
/>
</div>
</body>
</html>
</t>
</t>
</template>
<report id="report_res_partner_label"
string="Partner Labels"
model="res.partner"
name="partner_label.view_res_partner_label"
report_type="qweb-pdf"
paperformat="report.paperformat_euro"
paperformat="base.paperformat_euro"
/>
</odoo>

3
partner_label/tests/__init__.py

@ -1,4 +1 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_partner_label

14
partner_label/tests/test_partner_label.py

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests.common import TransactionCase
# Copyright 2017 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
class TestPartnerLabel(TransactionCase):
def test_partner_label(self):
settings = self.env['base.config.settings'].create({})
settings = self.env['res.config.settings'].create({})
settings.refresh()
self.assertItemsEqual(
settings.action_partner_labels_preview()['context']['active_ids'],
self.env['res.partner'].search([], limit=100).ids,
@ -17,10 +17,10 @@ class TestPartnerLabel(TransactionCase):
.paperformat_id
)
settings.partner_labels_paperformat_id = self.env.ref(
'report.paperformat_us'
'base.paperformat_us'
).id,
self.assertEqual(
self.env.ref('partner_label.report_res_partner_label')
.paperformat_id,
self.env.ref('report.paperformat_us')
self.env.ref('base.paperformat_us')
)

78
partner_label/views/base_config_settings.xml

@ -1,31 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_general_configuration" model="ir.ui.view">
<field name="model">base.config.settings</field>
<field name="inherit_id" ref="base_setup.view_general_configuration" />
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form" />
<field name="arch" type="xml">
<group name="report" position="after">
<group name="partner_labels" string="Labels configuration">
<label for="partner_labels_width" />
<div><field name="partner_labels_width" class="oe_inline" /> mm</div>
<label for="partner_labels_height" />
<div><field name="partner_labels_height" class="oe_inline" /> mm</div>
<label string="Margin"/>
<div class="oe_inline">
Top: <field name="partner_labels_margin_top" string="Top" class="oe_inline"/>mm,
Bottom: <field name="partner_labels_margin_bottom" string="Bottom" class="oe_inline"/>mm,
Left: <field name="partner_labels_margin_left" string="Left" class="oe_inline"/>mm,
Right: <field name="partner_labels_margin_right" string="Right" class="oe_inline"/>mm
<xpath expr="//div[@id='business_documents']" position="after">
<div id="partner_labels">
<h2>Labels configuration</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<div class="content-group">
<div class="mt16 row">
<label for="partner_labels_width" class="col-3 col-lg-3 o_light_label"/>
<field name="partner_labels_width" class="oe_inline" />mm
</div>
<div class="mt16 row">
<label for="partner_labels_height" class="col-3 col-lg-3 o_light_label"/>
<field name="partner_labels_height" class="oe_inline" />mm
</div>
<div class="mt16 row">
<label for="partner_labels_padding" class="col-3 col-lg-3 o_light_label"/>
<field name="partner_labels_padding" class="oe_inline" />mm
</div>
<div class="mt16 row">
<label for="partner_labels_paperformat_id" class="col-3 col-lg-3 o_light_label"/>
<field name="partner_labels_paperformat_id" class="oe_inline" />
</div>
<div class="mt16">
<button type="object" name="action_partner_labels_preview" string="Preview" class="oe_link" />
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<div class="content-group">
<div class="mt16 row">
<label for="partner_labels_margin_top" class="col-3 col-lg-3 o_light_label"/>
<field name="partner_labels_margin_top" class="oe_inline" />mm
</div>
<div class="mt16 row">
<label for="partner_labels_margin_bottom" class="col-3 col-lg-3 o_light_label"/>
<field name="partner_labels_margin_bottom" class="oe_inline" />mm
</div>
<div class="mt16 row">
<label for="partner_labels_margin_left" class="col-3 col-lg-3 o_light_label"/>
<field name="partner_labels_margin_left" class="oe_inline" />mm
</div>
<div class="mt16 row">
<label for="partner_labels_margin_right" class="col-3 col-lg-3 o_light_label"/>
<field name="partner_labels_margin_right" class="oe_inline" />mm
</div>
</div>
</div>
</div>
</div>
<label for="partner_labels_padding" />
<div><field name="partner_labels_padding" class="oe_inline" /> mm</div>
<label for="partner_labels_paperformat_id" />
<div>
<field name="partner_labels_paperformat_id" class="oe_inline" />
<button type="object" name="action_partner_labels_preview" string="Preview" />
</div>
</group>
</group>
</div>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save