Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] business_requirement_sale: New module in 11.0 #312

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion business_requirement_deliverable/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Copyright 2016-2019 Elico Corp (https://www.elico-corp.com).
# Copyright 2019 Tecnativa - Alexandre Díaz
# Copyright 2019 Tecnativa - Víctor M.M. Torres
# Copyright 2019 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Business Requirement Deliverable',
'category': 'Business Requirements Management',
'summary': 'Manage the Business Requirement Deliverables \
for your customers',
'version': '11.0.1.1.0',
'version': '11.0.1.2.0',
'website': 'https://www.elico-corp.com/',
"author": "Elico Corp, Odoo Community Association (OCA)",
'depends': [
Expand Down
5 changes: 2 additions & 3 deletions business_requirement_deliverable/controllers/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def portal_my_brd_list(self, page=1, date_begin=None, date_end=None,
# Force sort on br first to group by br in view
order = "business_requirement_id, %s" % order
elif groupby == 'section':
order = "business_requirement_deliverable_section_id, %s" % order
order = "section_id, %s" % order
brd_recs = BRDObj.search(domain, order=order,
limit=self._items_per_page,
offset=(page - 1) * self._items_per_page)
Expand All @@ -131,8 +131,7 @@ def portal_my_brd_list(self, page=1, date_begin=None, date_end=None,
elif groupby == 'section':
grouped_brd = [
BRDObj.concat(*g) for k, g in groupbyelem(
brd_recs, itemgetter(
'business_requirement_deliverable_section_id'))]
brd_recs, itemgetter('section_id'))]
else:
grouped_brd = [brd_recs]

Expand Down
39 changes: 27 additions & 12 deletions business_requirement_deliverable/models/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.addons import decimal_precision as dp

import logging
_logger = logging.getLogger(__name__)
from odoo.tools.misc import formatLang


class BusinessRequirementDeliverable(models.Model):
_name = "business.requirement.deliverable"
_inherit = ["mail.thread", "mail.activity.mixin", "portal.mixin"]
_description = "Business Requirement Deliverable"
_order = "sequence, id"
_order = "business_requirement_id, section_id, sequence, id"

sequence = fields.Integer('Sequence')
state = fields.Selection(
Expand Down Expand Up @@ -88,9 +86,11 @@ class BusinessRequirementDeliverable(models.Model):
state = fields.Selection(related='business_requirement_id.state',
string='State', store=True, readonly=True)
portal_published = fields.Boolean('In Portal', default=True)
business_requirement_deliverable_section_id = fields.Many2one(
section_id = fields.Many2one(
comodel_name='business.requirement.deliverable.section',
string='Section')
string='Section',
oldname='business_requirement_deliverable_section_id',
)

def _compute_portal_url(self):
super(BusinessRequirementDeliverable, self)._compute_portal_url()
Expand Down Expand Up @@ -173,6 +173,23 @@ def portal_publish_button(self):
self.ensure_one()
return self.write({'portal_published': not self.portal_published})

def name_get(self):
result = []
for rec in self:
name = '#{0}: {1} ({2})'
args = [
rec.sequence,
rec.name,
formatLang(
self.env, rec.price_total, currency_obj=rec.currency_id,
),
]
if rec.section_id:
name = '[{3}] #{0}: {1} ({2})'
args.append(rec.section_id.name)
result.append((rec.id, name.format(*args)))
return result


class BusinessRequirement(models.Model):
_inherit = "business.requirement"
Expand Down Expand Up @@ -306,17 +323,15 @@ def get_portal_confirmation_action(self):

def get_total_by_section(self):
sections_total = []
sections = self.deliverable_lines.mapped(
'business_requirement_deliverable_section_id')
sections = self.deliverable_lines.mapped('section_id')
for section in sections:
brd_lines = self.deliverable_lines.filtered(
lambda x: x.business_requirement_deliverable_section_id.id
== section.id)
lambda x: x.section_id == section
)
brd_section_total = sum(brd_lines.mapped('price_total'))
sections_total.append((section.name, brd_section_total))
# No Section
brd_lines = self.deliverable_lines.filtered(
lambda x: not x.business_requirement_deliverable_section_id)
brd_lines = self.deliverable_lines.filtered(lambda x: not x.section_id)
if any(brd_lines):
brd_section_total = sum(brd_lines.mapped('price_total'))
sections_total.append((_('Others'), brd_section_total))
Expand Down
2 changes: 1 addition & 1 deletion business_requirement_deliverable/views/br_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class='row'>
<div class="col-md-12">
<h2 t-field="deliverable.name"/>
<h4 t-field="deliverable.business_requirement_deliverable_section_id"/>
<h4 t-field="deliverable.section_id"/>
</div>
</div>
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
<th class="text-left" t-if="groupby == 'none'">Name</th>
<th class="text-left" t-elif="groupby == 'section'">
<em class="font-weight-normal text-muted">Deliverables for section:</em>
<t t-if="brd[0].sudo().business_requirement_deliverable_section_id">
<span t-field="brd[0].sudo().business_requirement_deliverable_section_id.name"/>
<t t-if="brd[0].sudo().section_id">
<span t-field="brd[0].sudo().section_id.name"/>
</t>
<t t-else="">
<span><i>Others</i></span>
Expand Down Expand Up @@ -101,8 +101,8 @@
<t t-call='portal.record_pager'/>
Business Requirement Deliverable - <span t-field="brd.name"/> (#<span t-esc="brd.sequence"/>)
<a class="btn btn-info" t-att-href="'/web#return_label=Website&amp;model=business.requirement.deliverable&amp;id=%s&amp;view_type=form' % (brd.id)" groups="business_requirement.group_business_requirement_manager">Edit Business Requirement Deliverable</a>
<t t-if="brd.business_requirement_deliverable_section_id">
<span class="label label-default" t-field="brd.business_requirement_deliverable_section_id.name" />
<t t-if="brd.section_id">
<span class="label label-default" t-field="brd.section_id.name" />
</t>
<t t-else="">
<span class="label label-default">Others</span>
Expand Down
4 changes: 2 additions & 2 deletions business_requirement_deliverable/views/business_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<filter string="Customer " icon="terp-go-home"
context="{'group_by':'business_requirement_partner_id'}" />
<filter string="Product" icon="terp-go-home" context="{'group_by':'product_id'}" />
<filter string="Section" icon="terp-go-home" context="{'group_by':'business_requirement_deliverable_section_id'}" />
<filter string="Section" icon="terp-go-home" context="{'group_by':'section_id'}" />
<filter string="State" icon="terp-go-home" context="{'group_by':'state'}" />
</group>
</search>
Expand Down Expand Up @@ -128,7 +128,7 @@
<group>
<group>
<field name="sequence"/>
<field name="business_requirement_deliverable_section_id"/>
<field name="section_id"/>
<field name="product_id" attrs="{'readonly':[('state','not in',['draft', 'confirmed'])]}"/>
<field name="state" invisible="1"/>
<field name="business_requirement_id" attrs="{'readonly':[('state','not in',['draft', 'confirmed'])]}"/>
Expand Down
79 changes: 79 additions & 0 deletions business_requirement_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
=========================
Business Requirement Sale
=========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbusiness--requirement-lightgray.png?logo=github
:target: https://github.com/OCA/business-requirement/tree/11.0/business_requirement_sale
:alt: OCA/business-requirement
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/business-requirement-11-0/business-requirement-11-0-business_requirement_sale
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/222/11.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of Business Requirement
and to allow you to convert into new Sale Orders.
Deliverables if selected will be Order Lines on the new Order created.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/business-requirement/issues>`_.
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
`feedback <https://github.com/OCA/business-requirement/issues/new?body=module:%20business_requirement_sale%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Alexandre Diaz
* Pedro M. Baeza
* Victor M.M. Torres

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/business-requirement <https://github.com/OCA/business-requirement/tree/11.0/business_requirement_sale>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions business_requirement_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2019 Tecnativa Victor M.M. Torres>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
from . import wizard
22 changes: 22 additions & 0 deletions business_requirement_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2019 Tecnativa Victor M.M. Torres>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Business Requirement Sale",
'category': 'Business Requirements Management',
'summary': 'Convert Business Requirement into Sales Orders',
"version": "11.0.1.0.0",
"website": "https://github.com/OCA/business-requirement",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": [
"business_requirement_deliverable",
"sale_management",
],
"data": [
'wizard/business_requirement_create_sale_views.xml',
'views/sale_order_views.xml',
'views/business_requirement_views.xml',
],
}
Loading