Browse Source

[MIG][12.0] partner_label

12.0
Holger Brunn 5 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. 18
      partner_label/reports/res_partner.xml
  7. 3
      partner_label/tests/__init__.py
  8. 14
      partner_label/tests/test_partner_label.py
  9. 76
      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 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", "name": "Partner labels",
"version": "10.0.1.0.0",
"version": "12.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)", "author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3", "license": "AGPL-3",
"category": "Base", "category": "Base",
"summary": "Print partner labels", "summary": "Print partner labels",
"depends": [ "depends": [
'base_setup', 'base_setup',
'report',
], ],
"data": [ "data": [
"views/base_config_settings.xml", "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 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): 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( partner_labels_width = fields.Float(
related='company_id.partner_labels_width', required=True, related='company_id.partner_labels_width', required=True,
readonly=False,
) )
partner_labels_height = fields.Float( partner_labels_height = fields.Float(
related='company_id.partner_labels_height', required=True, related='company_id.partner_labels_height', required=True,
readonly=False,
) )
partner_labels_padding = fields.Float( partner_labels_padding = fields.Float(
related='company_id.partner_labels_padding', required=True, related='company_id.partner_labels_padding', required=True,
readonly=False,
) )
partner_labels_margin_top = fields.Float( partner_labels_margin_top = fields.Float(
related='company_id.partner_labels_margin_top', related='company_id.partner_labels_margin_top',
required=True,
required=True, readonly=False,
) )
partner_labels_margin_bottom = fields.Float( partner_labels_margin_bottom = fields.Float(
related='company_id.partner_labels_margin_bottom', related='company_id.partner_labels_margin_bottom',
required=True,
required=True, readonly=False,
) )
partner_labels_margin_left = fields.Float( partner_labels_margin_left = fields.Float(
related='company_id.partner_labels_margin_left', related='company_id.partner_labels_margin_left',
required=True,
required=True, readonly=False,
) )
partner_labels_margin_right = fields.Float( partner_labels_margin_right = fields.Float(
related='company_id.partner_labels_margin_right', related='company_id.partner_labels_margin_right',
required=True,
required=True, readonly=False,
) )
partner_labels_paperformat_id = fields.Many2one( partner_labels_paperformat_id = fields.Many2one(
'report.paperformat', string='Paperformat', required=True, 'report.paperformat', string='Paperformat', required=True,
@ -57,7 +59,8 @@ class BaseConfigSettings(models.TransientModel):
@api.multi @api.multi
def action_partner_labels_preview(self): 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), self.env['res.partner'].search([], limit=100),
'partner_label.view_res_partner_label',
) )

18
partner_label/reports/res_partner.xml

@ -1,14 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<odoo> <odoo>
<template id="view_res_partner_label"> <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-call="web.basic_layout">
<t t-foreach="docs.with_context(show_address=True)" t-as="this"> <t t-foreach="docs.with_context(show_address=True)" t-as="this">
<div t-attf-style="height: {{this.company_id.partner_labels_height}}mm; <div t-attf-style="height: {{this.company_id.partner_labels_height}}mm;
width: {{this.company_id.partner_labels_width}}mm; width: {{this.company_id.partner_labels_width}}mm;
@ -22,18 +15,17 @@
float:left; float:left;
page-break-inside: avoid;"> page-break-inside: avoid;">
<address t-field="this.self" <address t-field="this.self"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'/>
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'
/>
</div> </div>
</t> </t>
</div>
</body>
</html>
</t>
</template> </template>
<report id="report_res_partner_label" <report id="report_res_partner_label"
string="Partner Labels" string="Partner Labels"
model="res.partner" model="res.partner"
name="partner_label.view_res_partner_label" name="partner_label.view_res_partner_label"
report_type="qweb-pdf" report_type="qweb-pdf"
paperformat="report.paperformat_euro"
paperformat="base.paperformat_euro"
/> />
</odoo> </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 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): class TestPartnerLabel(TransactionCase):
def test_partner_label(self): def test_partner_label(self):
settings = self.env['base.config.settings'].create({})
settings = self.env['res.config.settings'].create({})
settings.refresh()
self.assertItemsEqual( self.assertItemsEqual(
settings.action_partner_labels_preview()['context']['active_ids'], settings.action_partner_labels_preview()['context']['active_ids'],
self.env['res.partner'].search([], limit=100).ids, self.env['res.partner'].search([], limit=100).ids,
@ -17,10 +17,10 @@ class TestPartnerLabel(TransactionCase):
.paperformat_id .paperformat_id
) )
settings.partner_labels_paperformat_id = self.env.ref( settings.partner_labels_paperformat_id = self.env.ref(
'report.paperformat_us'
'base.paperformat_us'
).id, ).id,
self.assertEqual( self.assertEqual(
self.env.ref('partner_label.report_res_partner_label') self.env.ref('partner_label.report_res_partner_label')
.paperformat_id, .paperformat_id,
self.env.ref('report.paperformat_us')
self.env.ref('base.paperformat_us')
) )

76
partner_label/views/base_config_settings.xml

@ -1,31 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<odoo> <odoo>
<record id="view_general_configuration" model="ir.ui.view"> <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"> <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
</div>
<label for="partner_labels_padding" />
<div><field name="partner_labels_padding" class="oe_inline" /> mm</div>
<label for="partner_labels_paperformat_id" />
<div>
<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" /> <field name="partner_labels_paperformat_id" class="oe_inline" />
<button type="object" name="action_partner_labels_preview" string="Preview" />
</div> </div>
</group>
</group>
<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>
</div>
</xpath>
</field> </field>
</record> </record>
</odoo> </odoo>
Loading…
Cancel
Save