|
2 | 2 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
3 | 3 |
|
4 | 4 | from odoo import api, fields, models
|
5 |
| -from odoo.tools import float_compare |
6 | 5 |
|
7 | 6 |
|
8 | 7 | class PurchaseOrder(models.Model):
|
@@ -47,75 +46,3 @@ def _create_picking(self):
|
47 | 46 | # if it comes from manual confirmation
|
48 | 47 | return
|
49 | 48 | return super()._create_picking()
|
50 |
| - |
51 |
| - |
52 |
| -class PurchaseOrderLine(models.Model): |
53 |
| - _inherit = "purchase.order.line" |
54 |
| - |
55 |
| - qty_in_receipt = fields.Float( |
56 |
| - compute="_compute_qty_in_receipt", |
57 |
| - store=True, |
58 |
| - digits="Product Unit of Measure", |
59 |
| - help="Quantity for which there are pending stock moves", |
60 |
| - ) |
61 |
| - pending_to_receive = fields.Boolean( |
62 |
| - compute="_compute_qty_in_receipt", |
63 |
| - store=True, |
64 |
| - string="Pending Qty to Receive", |
65 |
| - help="There is pending quantity to receive not yet planned", |
66 |
| - ) |
67 |
| - |
68 |
| - @api.depends( |
69 |
| - "move_ids", |
70 |
| - "move_ids.state", |
71 |
| - "move_ids.location_id", |
72 |
| - "move_ids.location_dest_id", |
73 |
| - "product_uom_qty", |
74 |
| - "qty_received", |
75 |
| - "state", |
76 |
| - ) |
77 |
| - def _compute_qty_in_receipt(self): |
78 |
| - for line in self: |
79 |
| - precision_digits = self.env["decimal.precision"].precision_get( |
80 |
| - "Product Unit of Measure" |
81 |
| - ) |
82 |
| - total = 0.0 |
83 |
| - for move in line.move_ids: |
84 |
| - if move.state not in ["cancel", "done"]: |
85 |
| - if ( |
86 |
| - move.location_id |
87 |
| - == self.order_id.picking_type_id.default_location_dest_id |
88 |
| - ): |
89 |
| - # This is a return to vendor |
90 |
| - if move.to_refund: |
91 |
| - total -= move.product_uom._compute_quantity( |
92 |
| - move.quantity, line.product_uom |
93 |
| - ) |
94 |
| - elif ( |
95 |
| - move.origin_returned_move_id |
96 |
| - and move.origin_returned_move_id._is_dropshipped() |
97 |
| - and not move._is_dropshipped_returned() |
98 |
| - ): |
99 |
| - # Edge case: the dropship is returned to the stock, |
100 |
| - # no to the supplier. |
101 |
| - # In this case, the received quantity on the PO is |
102 |
| - # set although we didn't receive the product |
103 |
| - # physically in our stock. To avoid counting the |
104 |
| - # quantity twice, we do nothing. |
105 |
| - pass |
106 |
| - else: |
107 |
| - total += move.product_uom._compute_quantity( |
108 |
| - move.quantity, line.product_uom |
109 |
| - ) |
110 |
| - line.qty_in_receipt = total |
111 |
| - if ( |
112 |
| - float_compare( |
113 |
| - line.product_qty, |
114 |
| - line.qty_in_receipt + line.qty_received, |
115 |
| - precision_digits=precision_digits, |
116 |
| - ) |
117 |
| - == 1 |
118 |
| - ): |
119 |
| - line.pending_to_receive = True |
120 |
| - else: |
121 |
| - line.pending_to_receive = False |
0 commit comments