Skip to content

Commit

Permalink
[FIX]sale_commission: adjust settlement report spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
PicchiSeba committed Jul 22, 2024
1 parent 0207d7f commit b59fa8e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 13 deletions.
8 changes: 6 additions & 2 deletions sale_commission/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Sales commissions
=================

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand Down Expand Up @@ -96,6 +96,10 @@ For adding new agents:
You will also be able to see the settlements that have been made to this
agent from this page.


To show the partner in settlement lines:


Usage
=====

Expand Down Expand Up @@ -229,7 +233,7 @@ promote its widespread use.

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-pedrobaeza|
|maintainer-pedrobaeza|

This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/14.0/sale_commission>`_ project on GitHub.

Expand Down
21 changes: 21 additions & 0 deletions sale_commission/models/settlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def _default_currency(self):
string="Settlement lines",
readonly=True,
)
showable_line_ids = fields.One2many(
"sale.commission.settlement.line",
inverse_name="settlement_id",
readonly=True,
compute="_compute_total",
)
state = fields.Selection(
selection=[
("settled", "Settled"),
Expand Down Expand Up @@ -61,10 +67,18 @@ def _default_currency(self):
default=lambda self: self.env.user.company_id,
required=True,
)
show_partner_settlement_report = fields.Boolean(
related="company_id.show_partner_settlement_report",
)

@api.depends("line_ids", "line_ids.settled_amount")
def _compute_total(self):
for record in self:
record.showable_line_ids = record.line_ids
if record.company_id.settlement_skip_zero_amount_lines:
record.showable_line_ids = record.showable_line_ids.filtered(
lambda l: l.settled_amount
)
record.total = sum(record.mapped("line_ids.settled_amount"))

@api.depends("invoice_line_ids")
Expand Down Expand Up @@ -198,6 +212,13 @@ class SettlementLine(models.Model):
related="agent_line.object_id",
string="Source invoice line",
)
partner_id = fields.Many2one(
"res.partner",
related="invoice_line_id.partner_id",
)
show_partner_settlement_report = fields.Boolean(
related="company_id.show_partner_settlement_report",
)
agent_id = fields.Many2one(
comodel_name="res.partner",
readonly=True,
Expand Down
29 changes: 25 additions & 4 deletions sale_commission/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
: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 Expand Up @@ -450,6 +451,24 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
agent from this page.</p>
</li>
</ol>
<p>To show the partner in settlement lines:</p>
<ol class="arabic simple">
<li>Go to <em>Settings &gt; Sales &gt; Quotations &amp; Orders</em>:</li>
</ol>
<blockquote>
<ul class="simple">
<li>enable the setting “Show partner details in settlements report”</li>
</ul>
</blockquote>
<p>To hide lines with amount equals to 0:</p>
<ol class="arabic simple">
<li>Go to <em>Settings &gt; Sales &gt; Quotations &amp; Orders</em>:</li>
</ol>
<blockquote>
<ul class="simple">
<li>enable the setting “Skip lines in settlements with zero amount”</li>
</ul>
</blockquote>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
Expand Down Expand Up @@ -567,7 +586,9 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">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>
<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
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
10 changes: 3 additions & 7 deletions sale_commission/views/report_settlement_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<t t-call="web.internal_layout">
<div class="page">
<div class="row mt32 mb32">
<div class="col-xs-3" t-if="o.agent_id">
<div class="col-auto col-3 mw-100 mb-2" t-if="o.agent_id">
<strong>Agent:</strong>
<p t-field="o.agent_id" />
</div>
<div class="col-xs-2" t-if="o.date_from">
<div class="col-auto col-3 mw-100 mb-2" t-if="o.date_from">
<strong>From:</strong>
<p t-field="o.date_from" />
</div>
<div class="col-xs-2" t-if="o.date_to">
<div class="col-auto col-3 mw-100 mb-2" t-if="o.date_to">
<strong>To:</strong>
<p t-field="o.date_to" />
</div>
Expand All @@ -23,7 +23,6 @@
<thead>
<tr>
<th>Invoice date</th>
<th>Invoice</th>
<th>Invoice line</th>
<th>Commission</th>
<th class="text-right">Amount settled</th>
Expand All @@ -34,9 +33,6 @@
<td>
<span t-field="l.date" />
</td>
<td>
<span t-field="l.settlement_id.invoice_id" />
</td>
<td>
<span t-field="l.invoice_line_id" />
</td>
Expand Down

0 comments on commit b59fa8e

Please sign in to comment.