Skip to content

Commit

Permalink
[ADD] business_requirement_deliverable_sale: New module in 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Martin committed Jun 27, 2019
1 parent 1f4cc12 commit 297e98e
Show file tree
Hide file tree
Showing 14 changed files with 869 additions and 0 deletions.
86 changes: 86 additions & 0 deletions business_requirement_deliverable_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
================================
Business Requirement Deliverable
================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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_deliverable_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_deliverable_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 Deliverable
and to allow you to convert Requirement in new Sale Orders

**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_deliverable_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.

.. |maintainer-your-github-login| image:: https://github.com/your-github-login.png?size=40px
:target: https://github.com/your-github-login
:alt: your-github-login

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

|maintainer-your-github-login|

This module is part of the `OCA/business-requirement <https://github.com/OCA/business-requirement/tree/11.0/business_requirement_deliverable_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_deliverable_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
26 changes: 26 additions & 0 deletions business_requirement_deliverable_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2019 Tecnativa Victor M.M. Torres>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Business Requirement Deliverable",
'category': 'Business Requirements Management',
'summary': 'Convert Business Requirement into \
Sale Orders',
"version": "11.0.1.0.0",
"development_status": "Alpha",
"website": "https://github.com/OCA/business-requirement",
"author": "Tecnativa, "
"Odoo Community Association (OCA)",
"maintainers": ["your-github-login"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"business_requirement_deliverable",
"sale_management",
],
"data": [
'wizard/convert_requirement_sale.xml',
'views/sale_order_views.xml',
'views/business_requirement_views.xml',
],
}
5 changes: 5 additions & 0 deletions business_requirement_deliverable_sale/models/__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 business
from . import sale_order
89 changes: 89 additions & 0 deletions business_requirement_deliverable_sale/models/business.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright 2019 Tecnativa Victor M.M. Torres>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class BusinessRequirement(models.Model):
_inherit = 'business.requirement'

sale_order_ids = fields.One2many(
comodel_name='sale.order',
inverse_name='business_requirement_id',
string='Orders',
)
order_count = fields.Integer(
string='Count',
compute='_compute_order_count'
)
detailed_order = fields.Boolean(
help='Check this if need generated a detailed order'
)
product_id = fields.Many2one(
comodel_name='product.product',
string='Product',
domain=[('sale_ok', '=', True)],
)
qty = fields.Float(
string='Quantity',
default=1,
)
sale_price_unit = fields.Float(
string='Sales Price',
)

@api.multi
@api.onchange('product_id')
def product_id_change(self):
"""Get the right pricelist for product"""
uom_id = False
sale_price_unit = 0
product = self.product_id

if product:
uom_id = product.uom_id.id
sale_price_unit = product.list_price

sale_price_unit = self.product_id.list_price

if self.pricelist_id:
product = self.product_id.with_context(
lang=self.partner_id.lang,
partner=self.partner_id.id,
quantity=self.qty,
pricelist=self.pricelist_id.id,
uom=self.uom_id.id,
)
sale_price_unit = product.price

if uom_id:
self.uom_id = uom_id
self.sale_price_unit = sale_price_unit

@api.multi
@api.depends('sale_order_ids')
def _compute_order_count(self):
for order in self:
order.order_count = len(order.sale_order_ids)

@api.multi
def convert_requirement_sale(self):
vals = {
'br_id': self.id,
'brd_ids': [(6, 0, self.deliverable_lines.ids)]
}
wizard_obj = self.env['convert.requirement.sale']
wizard = wizard_obj.create(vals)
action = wizard.wizard_view()
return action

@api.multi
def launch_convert_wizard(self):
vals = {
'br_id': self.id,
'brd_ids': [(6, 0, self.deliverable_lines.ids)],
}
wizard_obj = self.env['convert.requirement.sale']
wizard = wizard_obj.create(vals)
action = wizard.wizard_view()
return action
13 changes: 13 additions & 0 deletions business_requirement_deliverable_sale/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019 Tecnativa Victor M.M. Torres>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SaleOrder(models.Model):
_inherit = 'sale.order'

business_requirement_id = fields.Many2one(
comodel_name='business.requirement',
string='Business requirement'
)
5 changes: 5 additions & 0 deletions business_requirement_deliverable_sale/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Alexandre Diaz
* Pedro M. Baeza
* Victor M.M. Torres
2 changes: 2 additions & 0 deletions business_requirement_deliverable_sale/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the functionality of Business Requirement Deliverable
and to allow you to convert Requirement in new Sale Orders
Loading

0 comments on commit 297e98e

Please sign in to comment.