Skip to content

Commit

Permalink
fix pre-commit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Kev-Roche committed Oct 27, 2022
1 parent 66f4b19 commit 3f3d2a1
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 26 deletions.
3 changes: 2 additions & 1 deletion sale_partner_primeship/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright 2021 Akretion - Florian Mounier
{
"name": "Sale Partner Primeship",
"summary": "Allow you to manage time limited prime memberships and prime membership activation products.",
"summary": """Allow you to manage time limited prime memberships
and prime membership activation products.""",
"version": "14.0.1.0.0",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
Expand Down
7 changes: 4 additions & 3 deletions sale_partner_primeship/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from odoo import api, fields, models
from dateutil.relativedelta import relativedelta

from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = "sale.order"
Expand Down Expand Up @@ -53,7 +54,7 @@ class SaleOrderLine(models.Model):
string="Primeships",
comodel_name="sale.primeship",
compute="_compute_primeship_id",
inverse="_compute_inverse_primeship_id",
inverse="_inverse_primeship_id",
)

# One2one impl
Expand All @@ -67,7 +68,7 @@ def _compute_primeship_id(self):
if record.primeship_ids:
record.primeship_id = record.primeship_ids[0]

def _compute_inverse_primeship_id(self):
def _inverse_primeship_id(self):
for record in self:
if record.primeship_ids:
primeship = record.env["sale.primeship"].browse(
Expand Down
14 changes: 6 additions & 8 deletions sale_partner_primeship/models/sale_primeship.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import api, fields, models
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


Expand Down Expand Up @@ -52,16 +52,14 @@ def _compute_current(self):
def _check_end_date(self):
for record in self:
if record.end_date < record.start_date:
raise ValidationError("The end date cannot be before start date")
raise ValidationError(_("The end date cannot be before start date"))

if any(
(
primeship.overlaps(record.start_date, record.end_date)
for primeship in record.partner_id.primeship_ids
if primeship.id != record.id
)
primeship.overlaps(record.start_date, record.end_date)
for primeship in record.partner_id.primeship_ids
if primeship.id != record.id
):
raise ValidationError("Primeships cannot overlaps")
raise ValidationError(_("Primeships cannot overlaps"))

def overlaps(self, start, end):
self.ensure_one()
Expand Down
2 changes: 1 addition & 1 deletion sale_partner_primeship/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go to the product form Sales tab and tick the Activates primeship checkbox:

You can then set a primeship duration.

You can see current primeship availability for a customer:
You can see current primeship availability for a customer:

.. figure:: ../static/description/partner-with-primeship.png

Expand Down
15 changes: 11 additions & 4 deletions sale_partner_primeship/views/product_template_views.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="product_template_only_form_view" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="inherit_id" ref="product.product_template_only_form_view" />
<field name="arch" type="xml">
<xpath expr="//page[@name='sales']" position="inside">
<group string="Primeships" name="primeships" attrs="{'invisible': [('type', '!=', 'service')]}">
<group
string="Primeships"
name="primeships"
attrs="{'invisible': [('type', '!=', 'service')]}"
>
<field name="primeship_activation" />
<field name="primeship_duration" attrs="{'invisible': [('primeship_activation', '=', False)]}"/>
<field
name="primeship_duration"
attrs="{'invisible': [('primeship_activation', '=', False)]}"
/>
</group>
</xpath>
</field>
Expand Down
19 changes: 15 additions & 4 deletions sale_partner_primeship/views/res_partner_views.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//div[@name='button_box']" position="inside">
<button class="oe_stat_button" name="%(sale_primeship_action)d" type="action" groups="sales_team.group_sale_manager" icon="fa-id-card" context="{'search_default_partner_id': commercial_partner_id, 'default_partner_id': commercial_partner_id}">
<button
class="oe_stat_button"
name="%(sale_primeship_action)d"
type="action"
groups="sales_team.group_sale_manager"
icon="fa-id-card"
context="{'search_default_partner_id': commercial_partner_id, 'default_partner_id': commercial_partner_id}"
>
<div class="o_form_field o_stat_info">
<div class="o_row">
<span class="o_stat_value">
<field string="Primeships" name="primeship_count" widget="integer"/>
<field
string="Primeships"
name="primeship_count"
widget="integer"
/>
</span>
</div>
<span class="o_stat_text">Primeships</span>
Expand Down
10 changes: 5 additions & 5 deletions sale_partner_primeship/views/sale_primeship_views.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="sale_primeship_search" model="ir.ui.view">
<field name="name">sale.primeship.search</field>
<field name="model">sale.primeship</field>
<field name="arch" type="xml">
<search>
<field name="start_date"/>
<field name="end_date"/>
<field name="partner_id"/>
<field name="current"/>
<field name="start_date" />
<field name="end_date" />
<field name="partner_id" />
<field name="current" />
</search>
</field>
</record>
Expand Down
6 changes: 6 additions & 0 deletions setup/sale_partner_primeship/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 3f3d2a1

Please sign in to comment.