Skip to content

Commit

Permalink
[ADD]purchase_reception_notify
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHForgeFlow authored and daylinglez committed Apr 18, 2021
1 parent 27230ea commit 8218e1c
Show file tree
Hide file tree
Showing 12 changed files with 640 additions and 0 deletions.
81 changes: 81 additions & 0 deletions purchase_reception_notify/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
=========================
Purchase Reception Notify
=========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/11.0/purchase_reception_notify
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-11-0/purchase-workflow-11-0-purchase_reception_notify
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/142/11.0
:alt: Try me on Runbot

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

This module notifies purchase users when the receptions are performed

This module creates a new message subtype specifically created for those
notifications. This subtype is internal activated by default when subscribing.

**Table of contents**

.. contents::
:local:

Usage
=====

Integrated in the normal flow.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/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/purchase-workflow/issues/new?body=module:%20purchase_reception_notify%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
~~~~~~~

* Eficent

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

* Aaron Henriquez <[email protected]>

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/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/11.0/purchase_reception_notify>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions purchase_reception_notify/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions purchase_reception_notify/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0).

{
'name': "Purchase Reception Notify",
'version': '11.0.1.0.0',
'category': 'Purchase Management',
'author': "Eficent, "
"Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/purchase-workflow',
'license': 'AGPL-3',
"depends": [
'purchase',
],
"data": ["data/mail.xml",
],
"installable": True
}
12 changes: 12 additions & 0 deletions purchase_reception_notify/data/mail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">

<record id="mt_purchase_reception" model="mail.message.subtype">
<field name="name">Purchase Receptions</field>
<field name="res_model">purchase.order</field>
<field name="default" eval="True"/>
<field name="internal" eval="True"/>
</record>
</data>
</odoo>
1 change: 1 addition & 0 deletions purchase_reception_notify/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_picking
57 changes: 57 additions & 0 deletions purchase_reception_notify/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).

from odoo import _, api, models


class StockPicking(models.Model):
_inherit = "stock.picking"

@api.model
def _purchase_order_picking_confirm_message_content(
self, picking, purchase_dict):
if not purchase_dict:
purchase_dict = {}
title = _('Receipt confirmation %s') % (
picking.name)
message = '<h3>%s</h3>' % title
message += _('The following items '
'have now been received in Incoming Shipment %s:') % (
picking.name)
message += '<ul>'
for purchase_line_id in purchase_dict.values():
message += _(
'<li><b>%s</b>: Received quantity %s %s</li>'
) % (purchase_line_id['purchase_line'].product_id.display_name,
purchase_line_id['stock_move'].product_qty,
purchase_line_id['stock_move'].product_uom.name,
)
message += '</ul>'
return message

@api.multi
def action_done(self):
super(StockPicking, self).action_done()
for picking in self:
purchase_dict = {}
if picking.picking_type_id.code != 'incoming':
continue
for move in picking.move_lines:
if move.purchase_line_id:
pol_id = move.purchase_line_id
if pol_id.id not in purchase_dict:
purchase_dict[pol_id.id] = {}
data = {
'purchase_line': pol_id,
'stock_move': move,
}
purchase_dict[pol_id.id][pol_id.id] = data
for purchase_line_id in purchase_dict:
po = self.env['purchase.order.line'].sudo().browse(
purchase_line_id).order_id
message = \
self._purchase_order_picking_confirm_message_content(
picking, purchase_dict[purchase_line_id])
po.message_post(
body=message,
subtype='purchase_reception_notify.mt_purchase_reception')
1 change: 1 addition & 0 deletions purchase_reception_notify/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Aaron Henriquez <[email protected]>
4 changes: 4 additions & 0 deletions purchase_reception_notify/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module notifies purchase users when the receptions are performed

This module creates a new message subtype specifically created for those
notifications. This subtype is internal activated by default when subscribing.
1 change: 1 addition & 0 deletions purchase_reception_notify/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Integrated in the normal flow.
Loading

0 comments on commit 8218e1c

Please sign in to comment.