Commit Graph

967 Commits

Author SHA1 Message Date
Denis Ledoux ae74ebb5ce [FIX] purchase: `related_usage` must be readonly
The `related_usage` field of `purchase.order`
is a related field to the location `usage` field,
which is defined in order to display/hide
some other field in the PO according to the location usage

This is purely a technical field, which is set only
to change the form view according to the location
usage.

This is not expected to change the location usage
through this field, this field must therefore
be set to readonly.

A change on the location usage could happen because
of the `onchange_picking_type_id`:
If the user changed the picking type, and then the location,
the usage returned by the `onchange_picking_type_id` was
applied on the location, and this must not have happened.

In addition, since `related_usage` is a related to the location
usage, it should be changed as well when the location is changed.
(in the new api, this is no longer required, the related field
is updated automatically).

This revision therefore adds an onchange on the location as well,
to handle this.

opw-676428
2016-06-16 11:32:10 +02:00
Nicolas Martinelli 63ca2d1b9f [FIX] purchase: wrong call to super
opw-675480
2016-05-30 11:24:10 +02:00
Olivier Dony cd3f52ba10 [FIX] account,*: preserve deactivated taxes
By default, when reading a m2m field, entries that are
deactivated in the destination table are not included.
This behavior is desirable in some cases (e.g. for
"tags" or "categories", but not for entries that
significantly impact other field values in the parent
record, such as taxes.

The problem is rather obvious: when displaying a
paid invoice that used taxes that are now deactivated,
the taxes are hidden while they still affect the
computed amount. And after cancelling + resetting
to draft, the tax is not taken into account anymore,
while still being linked.

Forcing the field-level (python) domain to include
both active and inactive entries solves the problem:
 - when reading, displaying and recomputing values,
   deactivated taxes will be included.
 - when trying to pick a tax, deactivated entries
   will still be ignored, as expected.

This commit applies the technique to all m2m
fields that refer to taxes.

Fixes #12066
opw-677751
2016-05-30 09:07:31 +02:00
Goffin Simon 7061acd2c1 [FIX] purchase: fiscal position from onchange_partner_id
Used case:

-Configure admin as multi-company user
-Create 2 fiscal positions (one for company "Odoo BE" and one for company "Odoo US")
-Set admin on company "Odoo BE"
-On supplier (Asustek) configure fiscal position Odoo BE
-Set admin on company "Odoo US"
-On supplier (Asustek) configure fiscal position Odoo US
-Configure a product (Laptop E5023) with:
   *route "Buy"
   *supplier (Asustek) without company
   *reordering rules (min qty: 20, max qty: 40)
-Set admin on company "Odoo BE"
-Run scheduler via the cron

Behavior before the fix:

-Fiscal position on the created PO is the fiscal position for "Odoo BE" (and PO is for the company "Odoo US")

Behavior after the fix:

-Fiscal position on the create PO is the fiscal position for "Odoo US".

Closes #11537

opw:673288
2016-05-12 13:05:52 +02:00
Nicolas Martinelli 529481991a [FIX] purchase: date planned
When a PO is copied, the date planned of the order lines should be
recomputed based on the order date.

opw-675480
2016-05-12 09:25:58 +02:00
Adrien Peiffer (ACSONE) 9ac9869a57
[FIX] purchase: Context propagation in wkf_confirm_order.
Closes #11916
2016-05-04 15:39:00 +02:00
Goffin Simon 6057e645d6 [FIX] purchase: Shipping exception when cancelling a PO
When canceling and clicking on "reset to draft" button a PO with
invoicing method = Based on generated draft invoice, the purchase
workflow led to a shipping exception.

To be in state done the PO must have:

All its PO lines invoiced with _set_po_lines_invoiced
All its incoming shipments done with test_moves_done

opw:673561
2016-04-19 08:47:22 +02:00
Nicolas Martinelli 560e5eec15 [FIX] purchase: duplicate origin in PO
When a "Drop Shipping" route is used on a product, the origin document
is duplicated on the PO created. This is because in this case,
po_rec.origin and procurement.origin are the same.

opw-671039
2016-03-09 15:57:00 +01:00
Goffin Simon 13c33264e6 [FIX] purchase: _get_po_line_values_from_proc-sig
Introduced by eefc76f
Only the supplier taxes of the company set in the procurement
must be set in the PO.

Backport from f5989bc3d8f10a0354a7d085576276d4e1778fbd

opw:671449
2016-03-09 13:16:14 +01:00
Josse Colpaert 45d4bd04cb [FIX] purchase: the stock should be valued without the taxes included from the purchase order line
From issue 660592. (already fixed in v9)  When products are received from a purchase line
with taxes included, the cost for the stock valuation (on the stock move) on reception
should be without these taxes included.
2016-02-26 11:45:22 +01:00
Denis Ledoux 9f7200a2f6 [FIX] purchase: origin concatenation
This is related to revision 44eeb38

The origin concatenation was not working
when `procurement.origin` was `False`

opw-666933
2016-01-15 17:51:31 +01:00
Alexis de Lattre a4e48d4c28 [FIX] product, purchase: pricelist of PO issued from procurements
When a purchase order is created through a procurement order,
the purchase order pricelist is taken from
the partner `property_product_pricelist_purchase`,
which is a property, which therefore can be different
according to the company. This is therefore
important to force the company to the procurement company
when browsing the partner, to get the correct pricelist,
from the right company. Otherwise, it take the pricelist
from the `SUPERUSER` company (when running the schedulers/cron),
which can be different than the procurement company.

The same as to be applied when browsing the product,
as the `standard_price` field (Cost Price) is a property
as well, and can be different according to the company,
in order to get the correct price unit on the purchase
order line, from the correct company.

Fixes #5329
Closes #5330
2016-01-04 11:35:23 +01:00
Danimar Ribeiro 1ac94db8e8 [FIX] context to map_tax
Missing context to map_tax calls
Fixes #9909
2015-12-15 16:10:16 +01:00
Goffin Simon eb993b7f3b [FIX] purchase: supplier taxes in onchange_product_id
When adding a line in a PO with the SUPERUSER_ID all the record rules
didn't apply on him. Then all the supplier taxes set on the  product
were written in the PO line even if some of its were not in the company
of the user. Then with the SUPERUSER_ID, just the company taxes of this
user must be applied. Inspired from product_id_change in model
'sale.order.line'.

opw:659236
2015-12-14 12:15:12 +01:00
Martin Trigaux 44eeb387d3 [FIX] purchase: updating existing PO should keep origin
When a make to order product is sold, a purchase order is created or added to an
existing one. In the second case, the origin of the sale order was lost.
It is now added to the existing source.

opw 656688
2015-12-01 15:23:46 +01:00
Nicolas Martinelli f18399f721 [FIX] purchase: invoice state of PO
If the invoicing policy of a PO is set to "Based on incoming shipments"
and the PO contains a product of type "service", it is never considered
as invoiced, and therefore reach the state "Done".

The reason is that no stock move is linked to this PO line, and
therefore it is never considered as invoiced since we check the invoice
state of the associated sotck moves.

This fix assumes that in this specific case, a PO line for a service is
always invoiced, since there is anyway no incoming shipment linked to
it.

opw-654317
2015-11-17 13:40:37 +01:00
Goffin Simon bdcae86d67 [FIX] purchase: invoiced purchase order line
When invoice_method == 'picking', a po line is invoiced if all the lines
linked to the po line are in invoices with state not in ['draft', 'cancel'].
To keep the same logic than before commit 9b1ab76.

opw:649746
2015-09-23 14:42:23 +02:00
Goffin Simon 14b060ed71 [FIX] purchase: journal_id in auto procurement
The journal_id used in a purchase.order created in auto procurement
(by the function make_po) must be the journal_id of the company_id
set on the procurement. The company_id set on the procurement is
the company_id set on the SO (function _prepare_order_line_procurement).

When creating the PO in function make_po, the company_id must be set in the
context to use the right journal_id with the function _get_journal in
"purchase.order" model.

opw:648600
2015-09-22 13:34:45 +02:00
Goffin Simon c092c40d14 [FIX] purchase: _calc_new_qty_price
The price must be compute with the purchase unit of measure set
on the product because qty is computed according to this unit of
measure.

opw:648513
2015-09-09 10:53:48 +02:00
Nicolas Lempereur a69af9c908 [FIX] addons: propagate context when get sequence
With 3e82c94d we use the timezone in the context to format date
sequences when formatting an ir.sequence.

This commit adds the other missing context when getting a sequence, so
these sequences are also dependant on the timezone.

closes #8351
opw-646487
2015-09-03 13:58:01 +02:00
Pedro M. Baeza 617ef49959 [IMP] purchase: Hook for the base price of a purchase line
To be able to change the logic without copying large chunk of code
Closes #1468
2015-08-27 17:42:20 +02:00
Goffin Simon 503820acb6 [FIX] account, purchase, sale: included taxes
-account:_fix_tax_included_price
If a fiscal position mapped an included tax on a SO or on a PO line
then the price unit of the product must be recomputed.

-purchase: onchange_product_id test
Test that when an included tax is mapped by a fiscal position, the included tax must be
subtracted to the price of the product.

-sale:product_id_change test
Test that when an included tax is mapped by a fiscal position, the included tax must be
subtracted to the price of the product.

opw:647321
2015-08-26 09:02:39 +02:00
Goffin Simon 6947313cd0 [FIX] purchase: customer lang
Introduced by f7f18ba5b1
The lang of the customer must be used.
In the drop shipping use case (order.location_id.usage == 'customer'), the customer
is in the destination address of the order (order.dest_address_id).

opw:647628
2015-08-24 11:37:09 +02:00
Goffin Simon f7f18ba5b1 [FIX] purchase: description of a product
When a move is creating from a purchase order line and the destination
of the order("location_id") is "customer", the description of the created
move must be the name of the product. To avoid that the supplier description
of the product appears on the customer invoice because in "drop shipping",
the customer invoice line is created with this created move by the function
"_get_invoice_line_vals".

opw:647628
2015-08-20 11:24:53 +02:00
Goffin Simon ad253a3386 [FIX] purchase, stock_dropshipping: origin in PO
When a product is in "dropshipping" with one supplier and with a few SO
created for the same customer, the origin of the resulting PO must
include all the SO names.

opw:647409
2015-08-18 11:01:27 +02:00
Nicolas Martinelli 9b1ab76eb2 [IMP] purchase: invoice state of PO line calculated from invoice state of move
Before this fix, a PO line was set as invoiced if all associated invoices were
validated. This is an issue if the invoice_method of a PO is set on 'picking',
and that only a partial quantity is received and invoiced. Indeed, in this case
it was never possible to meet the condition, and the PO could not be set to
'done'.

After this fix, the PO line invoice state is calculated from the invoice state
of the related moves, if the invoice_method of a PO is set on 'picking'. This
is more logical, and moreover this makes possible to set a PO line as invoiced
as soon as all the related moves are done or cancelled.

opw-644399
2015-08-03 09:04:43 +02:00
Nicolas Lempereur c1cb489ebe [FIX] purchase: uom for PO without product_id
When a purchase order line doesn't have a product_id, the current onchange
method would return False as uom_id since b675ff1, thus introducing an issue
since uom_id is required and the field may be not shown (so not changeable).

closes #7770
opw-646088
2015-07-28 16:50:52 +02:00
Nicolas Martinelli 24556120e7 [FIX] purchase: apply appropriate fiscal position when PO created automatically
When a PO is created automatically from a procurement, the fiscal position is
not chosen correctly. We need to choose the fiscal position in the same way if
the PO is created manually or automatically.

Follows commit 1062905acb

Fixes #3863
opw-643916
2015-07-07 16:08:11 +02:00
Christophe Simonis 066e41b63d [MERGE] forward port of branch saas-3 up to 31f2a1b 2015-06-30 13:33:35 +02:00
Christophe Simonis 31f2a1bc38 [MERGE] forward port of branch 7.0 up to 1c0bc7c 2015-06-30 12:47:27 +02:00
Daniel Dico a0797d3b35 [IMP] purchase: method action_picking_create return picking_id
Returning `picking_id` can be useful for overrides.

In addition, when there is no return statement,
the method basically returns None.
As this is a public method (not beginning with '_'), it can
be called with an xmlrpc call, and `None` is not an
accepted return value for the xmlrpc protocol.

Closes #1714
2015-06-26 15:56:42 +02:00
czoellner d226771383 [FIX] purchase: ensures invoice lines are linked to PO line
Fixes the impossibility to invoice purchase order lines, which were never
invoiced but set to invoiced by validating a first invoice created by invoice
control "manual".
2015-06-24 14:24:48 +02:00
sve-openerp cd1366a720 [FIX] purchase: Missing log in procurement chatter when deleting a PO line.
When a PO line is deleted, it sets the related procurements in exception.
This fix logs this action in the procurement chatter, for WMS administration
and maintenance purposes.
2015-06-22 14:34:35 +02:00
Nicolas Martinelli c7fad1313a [FIX] purchase: a procurement is done if all moves related are done
In case of a partial delivery of the products to receive, the procurement is
not considered as done since procurement.purchase_line_id.order_id.shipped is
false.

opw-641503
2015-06-17 06:50:20 +02:00
Nicolas Martinelli 5ada7bb0d0 [FIX] purchase: does not use minimum seller qty if delivery address is customer
This prevents to use the minimum quantity of the seller in case of dropshipping
2015-06-12 14:05:03 +02:00
Guewen Baconnier c315377d00 [IMP] purchase: Ignore canceled purchase lines
Canceled lines must be excluded from most of the operations done on a purchases orders.
The check has been done in some places but some of the loops on the order lines do not do it.
This commit correct them.
2015-06-08 18:19:38 +02:00
Nicolas Martinelli 9ce57d55e7 [FIX] purchase: add a trigger to minimum_date_planned
This triggers allows the minimum_date_planned to be calculated when PO are
merged.

opw-640541
2015-06-01 11:22:23 +02:00
Christophe Simonis e20dcda50d [MERGE] forward port of branch 7.0 up to 99c87b6 2015-05-21 16:33:45 +02:00
Olivier Dony 53980b7c52 [FIX] account, mail, etc.: uniformize evaluated expressions
opw-626694
2015-05-21 16:07:21 +02:00
Denis Ledoux 75aa699f62 [MERGE] forward port of branch saas-3 up to 6026c2f 2015-05-20 13:41:03 +02:00
Denis Ledoux 6026c2f4d0 [MERGE] forward port of branch 7.0 up to cc61d46 2015-05-20 13:39:39 +02:00
Goffin Simon cc61d467fa [FIX] purchase: validate invoice
A user that has the rights in Accounting & Finance equal to Invoicing & Payments
must have the right to validate a supplier invoice.

opw:634601
2015-05-19 14:14:07 +02:00
Christophe Simonis f722254018 [MERGE] forward port of branch saas-3 up to 0f5b6cf 2015-05-18 17:13:50 +02:00
Christophe Simonis 0f5b6cf60b [MERGE] forward port of branch 7.0 up to c435b84 2015-05-18 17:13:18 +02:00
Denis Ledoux acd61f8f0e [FIX] purchase: deletion of PO lines in states other than approved/done
This is related to revision 65d7cc524d

The `order_line` field of `purchase.order` is readonly within states
aprroved, done. See the field definition. This means it should be
possible to remove lines of a `purchase.order` when the PO is in
any other state than approved or done.

Therefore, the deletion of lines shouldn't be prevented
when the PO is not in state approved or done

opw-634538
2015-05-13 11:42:09 +02:00
Nicolas Martinelli 610a461099 [FIX] purchase: update and cancel of purchase order line takes into account existing procurements
Update:
When an existing purchase order line is updated, for example if a new procurement was required,
we check if the sum of existing running linked procurements is larger than the quantity in the
purchase order. If it is the case, we update the quantity and the unit price accordingly.
Without this fix, we systematically add the procurement quantity (or the provider minimum quantity)
to the purchase order line, even if the sum of the procurements is smaller than the ordered
quantity.

Cancel:
When a procurement is cancelled, we recompute the unit price of the associated purchase order
according to the quantity and make sure the provider minimum quantity is met. If the required
quantity is zero, we cancel and unlink the purchase order line.

opw: 632175 and 632176
2015-05-07 11:19:28 +02:00
Goffin Simon 1062905acb [IMP] purchase: fiscal positions
Automatic detection of a fiscal position is now working for Purchase.

opw:631554
2015-04-28 11:05:03 +02:00
Denis Ledoux cf4d14ce39 [MERGE] forward port of branch saas-3 up to 09b277c 2015-04-27 14:02:52 +02:00
Denis Ledoux d6ae7fb7db [MERGE] forward port of branch 7.0 up to 3e7d3c7 2015-04-27 12:19:43 +02:00
Martin Trigaux 316be12a3c [FIX] purchase: mark order as invoiced when fully invoiced only
Make sure the purchase order is marked as invoiced only when fully invoiced.
If the invoices are generated on delivery order (invoice_method picking), make
sure all products are delivered before setting it as invoiced.
opw 614256
2015-04-24 10:46:42 +02:00