Skip to content

Commit

Permalink
[IMP] pos_default_partner add continuation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime Arroyo committed Jul 3, 2020
1 parent 5a730a3 commit 0f0508a
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 69 deletions.
8 changes: 7 additions & 1 deletion pos_default_partner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand Down
2 changes: 1 addition & 1 deletion pos_default_partner/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"point_of_sale",
],
"data": [
"views/config_view.xml"
'views/pos_config.xml',
],
"website": "https://github.com/OCA/pos",
"installable": True,
Expand Down
3 changes: 1 addition & 2 deletions pos_default_partner/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from . import company
from . import config
from . import pos_order
from . import pos_config
11 changes: 0 additions & 11 deletions pos_default_partner/models/company.py

This file was deleted.

12 changes: 0 additions & 12 deletions pos_default_partner/models/config.py

This file was deleted.

14 changes: 14 additions & 0 deletions pos_default_partner/models/pos_config.py
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 5 deletions pos_default_partner/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 1 deletion pos_default_partner/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions pos_default_partner/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set the default customer also on the PoS UI.
28 changes: 17 additions & 11 deletions pos_default_partner/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,37 +373,43 @@ <h1 class="title">Point Of Sale Default Partner</h1>
<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
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_default_partner%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<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>
Expand All @@ -415,7 +421,7 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
</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
Expand Down
25 changes: 0 additions & 25 deletions pos_default_partner/views/config_view.xml

This file was deleted.

33 changes: 33 additions & 0 deletions pos_default_partner/views/pos_config.xml
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 0f0508a

Please sign in to comment.