Browse Source

[IMP] pos_default_partner add continuation

pull/515/head
Jaime Arroyo 4 years ago
parent
commit
0f0508a737
  1. 8
      pos_default_partner/README.rst
  2. 2
      pos_default_partner/__manifest__.py
  3. 3
      pos_default_partner/models/__init__.py
  4. 11
      pos_default_partner/models/company.py
  5. 12
      pos_default_partner/models/config.py
  6. 14
      pos_default_partner/models/pos_config.py
  7. 8
      pos_default_partner/models/pos_order.py
  8. 3
      pos_default_partner/readme/CONFIGURE.rst
  9. 1
      pos_default_partner/readme/ROADMAP.rst
  10. 28
      pos_default_partner/static/description/index.html
  11. 25
      pos_default_partner/views/config_view.xml
  12. 33
      pos_default_partner/views/pos_config.xml

8
pos_default_partner/README.rst

@ -35,7 +35,13 @@ Define a default partner for Point Of Sale order on each company.
Configuration
=============
Set default partner on POS settings
Go to Point of Sale's settings page and select a default customer for a
specific PoS configuration.
Known issues / Roadmap
======================
Set the default customer also on the PoS UI.
Bug Tracker
===========

2
pos_default_partner/__manifest__.py

@ -14,7 +14,7 @@
"point_of_sale",
],
"data": [
"views/config_view.xml"
'views/pos_config.xml',
],
"website": "https://github.com/OCA/pos",
"installable": True,

3
pos_default_partner/models/__init__.py

@ -1,3 +1,2 @@
from . import company
from . import config
from . import pos_order
from . import pos_config

11
pos_default_partner/models/company.py

@ -1,11 +0,0 @@
# copyright 2020 Akretion David BEAL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
pos_default_partner_id = fields.Many2one(
comodel_name="res.partner", string="Default customer")

12
pos_default_partner/models/config.py

@ -1,12 +0,0 @@
# copyright 2020 Akretion David BEAL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
pos_default_partner_id = fields.Many2one(
comodel_name="res.partner", readonly=False,
related="company_id.pos_default_partner_id")

14
pos_default_partner/models/pos_config.py

@ -0,0 +1,14 @@
# Copyright 2020 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class PosConfig(models.Model):
_inherit = 'pos.config'
default_partner_id = fields.Many2one(
comodel_name="res.partner",
string="Default Customer",
)

8
pos_default_partner/models/pos_order.py

@ -9,9 +9,7 @@ class PosOrder(models.Model):
@api.model
def create(self, vals):
if not vals.get("partner_id"):
company_id = vals.get("company_id") or self.env.user.company_id.id
partner = self.env["res.company"].browse(company_id).pos_default_partner_id
if partner:
vals["partner_id"] = partner.id
session = self.env["pos.session"].browse(vals.get("session_id"))
if session.config_id.default_partner_id and not vals.get("partner_id"):
vals["partner_id"] = session.config_id.default_partner_id.id
return super().create(vals)

3
pos_default_partner/readme/CONFIGURE.rst

@ -1 +1,2 @@
Set default partner on POS settings
Go to Point of Sale's settings page and select a default customer for a
specific PoS configuration.

1
pos_default_partner/readme/ROADMAP.rst

@ -0,0 +1 @@
Set the default customer also on the PoS UI.

28
pos_default_partner/static/description/index.html

@ -373,21 +373,27 @@ ul.auto-toc {
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>Set default partner on POS settings</p>
<p>Go to Point of Sale’s settings page and select a default customer for a
specific PoS configuration.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id2">Known issues / Roadmap</a></h1>
<p>Set the default customer also on the PoS UI.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
@ -395,15 +401,15 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul>
<li><p class="first">Akretion</p>
<blockquote>
@ -415,7 +421,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose

25
pos_default_partner/views/config_view.xml

@ -1,25 +0,0 @@
<?xml version="1.0"?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@data-key='point_of_sale']" position="inside">
<h2>POS customer</h2>
<div class="row mt16 o_settings_container" id="default_customer">
<div class="col-xs-12 col-md-12 o_setting_box">
<div>
<label for="pos_default_partner_id"/>
<div class="content-group mt16">
<field name="pos_default_partner_id" class="o_light_label"/>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

33
pos_default_partner/views/pos_config.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 Creu Blanca
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="pos_config_view_form">
<field name="name">pos.config.form (in pos_default_partner)</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='inventory_location']" position="after">
<h2>Customers</h2>
<div class="row mt16 o_settings_container" id="customers_config">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="default_partner_id" string="Default Customer"/>
<div class="text-muted">
Default customer to use if none is set
</div>
<div class="content-group mt16">
<field name="default_partner_id"/>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save